Thanks,
Joel
From: | Joel Leach |
To: | Rick Strahl |
Thanks,
Joel
IIS marshals STA threads for a particular session to a single thread always so that the STA component is always launched on the same thread.
This isn't just one thread for all users, but one thread per user via the tracking session cookie.
Still - STA is very very inefficient for IIS to process.
If you run your same sample with multiple browsers (ie. separate sessions) then you should see the sleep not effect the other session.
+++ Rick ---
protectedvoid Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); Response.Write("ASP.NET Thread " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()); }
Be sure to set AspCompat ="true" in the page, then run the app and open the page in two tabs. Click the button on the first tab, then quickly switch to the second tab and click the button. You'll notice the first tab request has to complete before the second tab request starts, and afterwards the page reports that both requests ran on the same thread. Set AspCompat = "false" and rerun the tests. This time both requests run simultaneously and in different threads. At least this is what is happening in my tests.
Is this all by design? I know you need to use AspCompat for COM interop, but a user ought to be able to perform multiple tasks in multiple tabs like a normal web page, don't you think? Is there a configuration setting to modify this behavior?
Thanks,
Joel