<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET AJAX Discussion and Suggestions</title><link>http://forums.asp.net/1007.aspx</link><description>This forum is the place for ASP.NET AJAX 'getting started' questions, general questions that don't fit in one of the other forums about AJAX </description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/2862842.aspx</link><pubDate>Mon, 12 Jan 2009 19:10:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2862842</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2862842.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=2862842</wfw:commentRss><description>&lt;p&gt;That site is wrong I&amp;#39;m afriad to say. There&amp;#39;s only 1 thread in JavaScript. You can appear to duplicate the&amp;nbsp;conditions of multiple threads if you involve modal dialogs, such as an alert(), but ajax apps wouldnt typically do that, and even if they do, there&amp;#39;s a really simple workaround to ensure you dont get a race condition -- call the alert() on a setTimeout call, so you don&amp;#39;t pause execution of the current call stack. A mutex simply is not necessary in JavaScript.&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/2862072.aspx</link><pubDate>Mon, 12 Jan 2009 13:27:57 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2862072</guid><dc:creator>thedoug</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2862072.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=2862072</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Then, why this site says that there is race conditions with AJAX? &lt;/p&gt;&lt;p&gt;http://www.developer.com/lang/jscript/article.php/3592016 &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;There are many others sites saying about mutexes in javascript.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;I need this information. The AJAX callbacks are processed in paralell?&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Thanks........ &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/2257627.aspx</link><pubDate>Wed, 26 Mar 2008 21:31:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2257627</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2257627.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=2257627</wfw:commentRss><description>&lt;p&gt;There is no race condition on &amp;#39;cbCount&amp;#39;. Even if the two requests complete at the same time, only one callback is going to execute at a time -- each one in its entirety, because there&amp;#39;s no concurrency or multi-threading in javascript. Rather, when the 2nd request completes, a &amp;#39;task&amp;#39; is queued to execute its callback, which can&amp;#39;t occur until there&amp;#39;s no other javascript already running.&lt;/p&gt;
&lt;p&gt;People I think believe there&amp;#39;s concurrency because they&amp;#39;ll insert an alert() into the callback to try to prove it. If you do that you will indeed see two different alerts come up at the same time. But that&amp;#39;s not because they are executing at the&amp;nbsp;same time, it&amp;#39;s because alert() causes the browser to defer execution of the rest of the context and move on to something else. If you use any other means to try and prove concurrency, you will fail, because there isn&amp;#39;t any. If you are going to have alerts() in your code then &lt;em&gt;maybe&lt;/em&gt; you need to worry about this kind of thing.&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/2257600.aspx</link><pubDate>Wed, 26 Mar 2008 21:17:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2257600</guid><dc:creator>indo_gangsta</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2257600.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=2257600</wfw:commentRss><description>&lt;p&gt;LudovicoVan, Your above code has a race condition for the variable &amp;quot;cbCount&amp;quot;.&lt;/p&gt;
&lt;p&gt;Seriously, does anyone know of mutex implementation for ASP.NET Ajax? The above code is a good example of why we need one.&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1475625.aspx</link><pubDate>Fri, 24 Nov 2006 16:07:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1475625</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1475625.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1475625</wfw:commentRss><description>&lt;p&gt;Hello back, here is maybe a more significant example.&lt;/p&gt;
&lt;p&gt;Say we have to issue two server calls returning an integer, then get the sum of the two integers and use that in a third function. We are not guaranteed the order of execution for the two callbacks, neither we actually know when they are going to return a value at all. How we could "architect" this? Here is some code, not perfect because it still is a generic sample, so no point in "optimizing", yet should give some hints:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;var cbCount, cbValue1, cbValue2;&lt;br /&gt;&lt;br /&gt;// Whatever the timing, these two callbacks&lt;br /&gt;// won't run concurrently, so no need&lt;br /&gt;// for a synchronization mechanism&lt;br /&gt;function httpCallback1(v) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; cbValue1 = parseInt(v, 10);&lt;br /&gt;&amp;nbsp;&amp;nbsp; if(++cbCount == 2) finishProcess();&lt;br /&gt;}&lt;br /&gt;function httpCallback2(v) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; cbValue2 = parseInt(v, 10);&lt;br /&gt;&amp;nbsp;&amp;nbsp; if(++cbCount == 2) finishProcess();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function startProcess() {&lt;br /&gt;&amp;nbsp;&amp;nbsp; cbCount = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;startHttpReq1(httpCallback1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;startHttpReq2(httpCallback2);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function finishProcess() {&lt;br /&gt;&amp;nbsp;&amp;nbsp; var sum = cbValue1 + cbValue2;&lt;br /&gt;&amp;nbsp;&amp;nbsp; alert(sum);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;startProcess();&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;A bit improperly, anyway here we might think of the cbCount as a "semaphore".&lt;/p&gt;
&lt;p&gt;Hope this can shed more light. (Does it?)&amp;nbsp;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1474343.aspx</link><pubDate>Thu, 23 Nov 2006 03:39:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1474343</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1474343.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1474343</wfw:commentRss><description>&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;What is my example then?&amp;nbsp; Here's a definition out of Wikipedia "&lt;em&gt;Concurrency occurs when two or more execution flows are able to run simultaneously." &amp;nbsp;&lt;/em&gt;What am I missing?&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;JS is not concurrent, that is you never ever have two paths of execution running at the same time in the context of the same host (in our case, a browser's window). What you get is incorrect sequence of execution, not concurrent execution.&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Like I said previous,&amp;nbsp;this example was a demonstration of concurrency&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;Again, it is not concurrent. It just shows a messed-up flow.&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;I can repeat the same behavior with asynchronous callbacks, that is I can make a request that calls one of my callback functions in parallel to another function executing.&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;This should simply not be the case, so maybe post a sample...&lt;/p&gt;
&lt;p&gt;In the meantime I'll tell you that this approach would mess the flow up:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; // Which runs first?&lt;br /&gt;&amp;nbsp;&amp;nbsp; StartHttpRequest(httpCallback);&lt;br /&gt;&amp;nbsp;&amp;nbsp; StartTimer(timerCallback, 2000);&lt;br /&gt;&amp;nbsp;&amp;nbsp; function httpCallback() { doSomethingFirst(); }&lt;br /&gt;&amp;nbsp;&amp;nbsp; function timerCallback() { doSomethingAfter(); }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;This approach instead would work reliably:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; StartHttpRequest(httpCallback);&lt;br /&gt;&amp;nbsp;&amp;nbsp; function httpCallback() { doSomethingFirst(); doSomethingAfter(); }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;There is no concurrency, it is a matter of "sequence". -LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1474100.aspx</link><pubDate>Wed, 22 Nov 2006 21:42:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1474100</guid><dc:creator>aosipov</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1474100.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1474100</wfw:commentRss><description>I have seen this same problem w/o using alerts but with XTR callbacks.&amp;nbsp;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1474096.aspx</link><pubDate>Wed, 22 Nov 2006 21:35:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1474096</guid><dc:creator>InfinitiesLoop</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1474096.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1474096</wfw:commentRss><description>I think it may appear that there is concurrency when in fact there isn't... when an Alert is open, the browser may divide the code into seperate tasks, and there are situations where other code may run while the original alert is open. But without the alert there could not be any concurrency. Basically using alert to try and prove concurrency isn't going to work. You can get multiple paths through the same code using this trick but only if you introduce an alert -- it cant happen otherwise.</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1473794.aspx</link><pubDate>Wed, 22 Nov 2006 17:09:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1473794</guid><dc:creator>aosipov</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1473794.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1473794</wfw:commentRss><description>&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;LudovicoVan:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Not only you can control the sequence of events, but - again - there simply is NO CONCURRENCY in JS.&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;What is my example then?&amp;nbsp; Here's a definition out of Wikipedia "&lt;em&gt;Concurrency occurs when two or more execution flows are able to run simultaneously." &amp;nbsp;&lt;/em&gt;What am I missing?&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;LudovicoVan:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;The basic problem (IMHO) is that you are mixing concepts from other languages completely different from the JS and its runtime model. That's why I am basically only stressing that you should know your language, rather than ask for foreign constructs you are more familiar with. Those constructs simply do not apply here!&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;To guarantee atomicity I use a mutex.&amp;nbsp; This is a concept that applies to languages that are able to execute flows simultaneously.&amp;nbsp; Javascript may not be such a language and I am not agruing that it is.&amp;nbsp; The implemention of Javascript in IE and Opera (but NOT FIREFOX) allows for parallel execution and thus arises my need for concurrency control.&amp;nbsp; The IE and Opera javascript runtime model (to use your words) allows for concurrency as demonstrated by my example (I am sure this was a design decision to allow faster rendering).&amp;nbsp; In a perfect world, Javascript would be single threaded and would lock the window global object to updates until the current code is finished executing - this would guarantee a safe environment where no race conditions can occur.&amp;nbsp; This is what Firefox does.&amp;nbsp; To restate again, this is NOT the case in IE and Firefox.&amp;nbsp; Therefore I need to guarantee some of my updates are atomic and therefore I use mutex implementation.&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;LudovicoVan:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;The code above is simply wrong. It misbehaves because you have written it so that it cannot but misbehave...&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;Like I said previous,&amp;nbsp;this example was a demonstration of concurrency showing the base problem (in the simplest way I could think of).&amp;nbsp; I can repeat the same behavior with asynchronous callbacks, that is I can make a request that calls one of my callback functions in parallel to another function executing.&amp;nbsp; The reason I made this example is because it is much easier to catch because there is no timing involved and I can control the timing myself and preproduce the problem every time, rarther than reproducing the problem under certain circumstances that are hard to simulate in an example (if not impossible w/o extensive retries).&lt;/p&gt;
&lt;p&gt;I am not sure how I am incorrect here.&amp;nbsp; LV, I too appreciate your effort to uncover the real needs here!!!&amp;nbsp; I understand your point that javascript doesn't have concurrency but in the real world of browsers we must work around different implementations so I am looking for the best way to do this and possibly get this included in a standard framework (AJAX).&amp;nbsp; This is pretty important.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1473750.aspx</link><pubDate>Wed, 22 Nov 2006 16:26:59 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1473750</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1473750.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1473750</wfw:commentRss><description>&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;I cannot control the sequence of events (at least in IE and Opera) and cannot guaruantee that a function will not run concurrently.&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;Not only you can control the sequence of events, but - again - there simply is NO CONCURRENCY in JS.&lt;/p&gt;
&lt;p&gt;The basic problem (IMHO) is that you are mixing concepts from other languages completely different from the JS and its runtime model. That's why I am basically only stressing that you should know your language, rather than ask for foreign constructs you are more familiar with. Those constructs simply do not apply here!&lt;strong&gt;*&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;I could be wrong but I am pretty sure my example shows the fundamental problem (of course not in a real world scenario).&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;The code above is simply wrong. It misbehaves because you have written it so that it cannot but misbehave...&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Am I on crazy pills?&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;Incorrect is not crazy, and I appreciate your efforts to get deeper.&lt;/p&gt;
&lt;p&gt;So, now I'll stop and wait with you for more feedback, in case anybody has something to add.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-LV&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;*&lt;/strong&gt;With an analogy: var x = "2" + "2" not giving back 4 doesn't imply - say - that JS lacks operator overloading, it would rather imply the programmer doesn't know what (s)he is doing...&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1473707.aspx</link><pubDate>Wed, 22 Nov 2006 16:02:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1473707</guid><dc:creator>aosipov</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1473707.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1473707</wfw:commentRss><description>&lt;p&gt;This was a proof of concept in the most simple example that I could make without adding complexity of a real world application.&amp;nbsp; I have experienced similar problems (concurrency based) in real world applications but I cannot post this code nor would anyone examine it.&amp;nbsp; To get back to the real problem, with asynchronous callbacks I cannot control the sequence of events (at least in IE and Opera) and cannot guaruantee that a function will not run concurrently.&amp;nbsp; This is not a problem for me as my code is already ready for such guaranteeing critical sections and critical data are locked during execution.&amp;nbsp; The point of this post was to get Atlas/AJAX team to recognize that a problem exists and possibly get a generic solution included in AJAX so we don't have to roll out our own custom solutions.&amp;nbsp; This seems to be a general enough problem that a lot of programming languages or standard libraries include mechanisms to work around it and it seems reasonable for AJAX as a client side library to provide a similar mechanism.&amp;nbsp; I could be wrong but I am pretty sure my example shows the fundamental problem (of course not in a real world scenario).&lt;/p&gt;
&lt;p&gt;Am I on crazy pills?&amp;nbsp; I would love not to have to resort to such complexity in javascript if someone can explain to me a viable alternative to guarantee my global memory will not be corrupted/modified concurrently.&amp;nbsp; Please help!&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1473544.aspx</link><pubDate>Wed, 22 Nov 2006 14:12:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1473544</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1473544.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1473544</wfw:commentRss><description>&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Here's a simple example where I think a Mutex implementation may be necessary.&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;I'm afraid your sample is not&amp;nbsp;very much significant. Apart from the fact that it is quite far from any real life code,&amp;nbsp;the basic problem is that - as said before - in JS the "sequence" of the messages is what matters, and&amp;nbsp;you have actually messed that up, so that it can't but misbehave...&amp;nbsp;you wrote it to do it! (E.g. you call "before" what you are really executing "after", and you try to get results from the same opening method, while you should really do that from the popup *after* the popup has finished...)&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;aosipov:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;By the way, the mutex implementation is only 30 lines (not 10,000 as you say).&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;10000 stands for far-too-many, and I was talking about the client-side frameworks in general there.&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1472605.aspx</link><pubDate>Tue, 21 Nov 2006 17:29:24 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1472605</guid><dc:creator>aosipov</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1472605.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1472605</wfw:commentRss><description>&lt;p&gt;Hi again LV - I am glad someone is interested in figuring this out with me.&lt;/p&gt;
&lt;p&gt;Here's a simple example where I think a Mutex implementation may be necessary.&amp;nbsp; Create the following page and then launch in IE (make sure to allow popups and not using tabs for new windows!).&lt;/p&gt;&lt;pre class=coloredcode&gt;&amp;lt;&lt;span class=tag&gt;html&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span class=tag&gt;head&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=tag&gt;title&lt;/span&gt;&amp;gt;My test page&amp;lt;/&lt;span class=tag&gt;title&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class=tag&gt;head&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span class=tag&gt;body&lt;/span&gt;&amp;gt;

&amp;lt;&lt;span class=tag&gt;script&lt;/span&gt;&lt;span class=attr&gt; type=&lt;/span&gt;&lt;span class=attrv&gt;"text/javascript"&lt;/span&gt;&amp;gt;
var o = window.opener;
function changeParentValueInParallel() {
  if (o &amp;amp;&amp;amp; !o.closed) {
    o.changeValue('b');
    alert('Parent property changed');
  }
}

window.MyProperty = 'a';
if (!(o &amp;amp;&amp;amp; !o.closed)) {
  window.changeValue = function(v) {
    window.MyProperty = v;
  }
  
  window.open(window.location);
  alert('Stage pre change parent window.MyProperty: ' +
        window.MyProperty +
        '\n\n' +
        'Before clicking OK press the Click me button in the child window');
  alert('Stage post change parent window.MyProperty: ' + window.MyProperty);
}

&amp;lt;/&lt;span class=tag&gt;script&lt;/span&gt;&amp;gt;

&amp;lt;&lt;span class=tag&gt;input&lt;/span&gt;&lt;span class=attr&gt; type=&lt;/span&gt;&lt;span class=attrv&gt;"button"&lt;/span&gt;&lt;span class=attr&gt; name=&lt;/span&gt;&lt;span class=attrv&gt;"invoke"&lt;/span&gt;&lt;span class=attr&gt; onclick=&lt;/span&gt;&lt;span class=attrv&gt;"changeParentValueInParallel();"&lt;/span&gt;&lt;span class=attr&gt; value=&lt;/span&gt;&lt;span class=attrv&gt;"Click me"&lt;/span&gt;/&amp;gt;

&amp;lt;/&lt;span class=tag&gt;body&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span class=tag&gt;html&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;p&gt;Here are the steps to reproducing the concurrency.&amp;nbsp; Open the page, then on the parent page there will be an alert - DO NOT CLICK OK, go into the newly opened page (child) and click the button.&amp;nbsp; Then click OK on the parent page.&amp;nbsp; What you will see in IE and Opera (FF behaves in&amp;nbsp;what I consider to be correct behavior) is the parent's window value be changed by the child while I am still in the function.&amp;nbsp; Alas, this is exactly what parallel execution is, and thus the need for mutex (or some other mechanism).&amp;nbsp; I don't think I have to explain how this can damage code, this is fairly standard textbook.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;It is my guestimate that the XTR objects and ActiveX behave the same way in IE as well as Opera (does anyone have access to Safari at the moment to test this).&lt;/p&gt;
&lt;p&gt;Julio, I am not sure how a simple flag would be able to help here.&amp;nbsp; Would love to know what other ways other than mutex implementation would work here to prevent this sort of thing in critical sections.&amp;nbsp; By the way, the mutex implementation is only 30 lines (not 10,000 as you say).&lt;/p&gt;
&lt;p&gt;Everyone, please chime in here this is fairly important (I think).&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1472236.aspx</link><pubDate>Tue, 21 Nov 2006 11:17:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1472236</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1472236.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1472236</wfw:commentRss><description>&lt;p&gt;Oh yeah: BTW, the &lt;font face="courier new,courier"&gt;fileRef &lt;/font&gt;variable you can see there is a perfect instance of the "flags" I was talking about above.&lt;/p&gt;
&lt;p&gt;-LV&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Mutex + Javascript in AJAX rtm?</title><link>http://forums.asp.net/thread/1472228.aspx</link><pubDate>Tue, 21 Nov 2006 11:04:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1472228</guid><dc:creator>LudovicoVan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1472228.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1007&amp;PostID=1472228</wfw:commentRss><description>&lt;p&gt;For reference, I'll give a sample about where a timing issue can occur and how easy it is to prevent any problem in idiomatic JS.&lt;/p&gt;
&lt;p&gt;The full source is here: &lt;a href="http://forums.asp.net/ShowPost.aspx?PostID=1456947"&gt;http://forums.asp.net/ShowPost.aspx?PostID=1456947&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once you have got what that does, just focus on this simple fragment:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; // Keep order!&lt;br /&gt;&amp;nbsp;&amp;nbsp; fileDsp.innerHTML = "&amp;lt;&lt;span class=tag&gt;em&lt;/span&gt;&amp;gt;Loading...&amp;lt;/&lt;span class=tag&gt;em&lt;/span&gt;&amp;gt;";&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; fileImg.src = fileBox.value;&lt;br /&gt;&amp;nbsp;&amp;nbsp; //&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Since this code is loading a local file*, assigning to the src property of the image immediately triggers the onload event for the image. But assigning to the innerHTML property too enqueues an interface update. Bottom line, if you revert the order of the statements above, you do not get correct results, because the sequence in which you enqueue events is the sequence in which they get then run!!!&lt;/p&gt;
&lt;p&gt;And, this is true for JS in web pages as well as it is true for any ECMA-based language, like it was JS in VRML, like it is AS in Flash, and so on.&lt;/p&gt;
&lt;p&gt;I hope this can shed a bit more light, anyway if you guys have any significant sample that you would like to see analyzed and refactored to "true" JS, please don't be shy and post it. IMHO, it might be a very instructive "case-study" for everybody trying to find their way with client-side programming.&lt;/p&gt;
&lt;p&gt;-LV&lt;/p&gt;
&lt;p&gt;*If the file was not local, the timing issue involved &lt;em&gt;might &lt;/em&gt;not show up. Yet, that is the way to go in general, for robust JS programming... We don't need mutexes, neither we miss OO-JS. We better simply know our language...&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>