Can an ASP.NET application be forced to run single-threaded?

G

Guest

We inherited an ASP.NET application which is not thread-safe. Many copies of
this application are in the field and customers are having problems, which we
believe is due to the thread safety problem.

Is there any way to configure IIS to run single-threaded, so that these
customers can get along without errors until we can get them updated software?

Some will have IIS 5.0 ( Win2K and WinXP ) and some will have IIS 6.0 (
Win03 ). For the Win03 servers, we have set the "worker processes" in the
application pool to be 1. But we are not convinced this is truly making the
app single threaded. Is it? For IIS 5.0, we don't know how to single thread
it, or if it's even possible.

Thanks!
Robb
 
G

Guest

The server is not coded to be multi-threaded. It does not start any
additional threads. However from the reading I've done, and from what we are
observing, it appears that IIS runs all apps in multiple worker-threads. So
if 2 clients call this server at the same time, 2 threads are spawned by IIS
to handle the requests in parallel. Right now we are stopping this by
putting a giant lock{} arround the entire method called by the client. But
that requires a code change, of course. I'm looking for a way to tell IIS (
5 and 6 ) NOT to spawn more than 1 worker thread at a time, so that it is
always processing only 1 client request at a time.

thanks
Robb
 
J

Joshua Flanagan

As an ugly hack (which it sounds like you are looking for), this might work:

Create a new assembly with a custom IHttpModule. Have the module handle
the BeginRequest method of the HTTP pipeline. Have it lock on a global
object of some sort (maybe an OS mutex? - look into the WaitHandle class
-I'm just guessing right now).

You can then distribute the new assembly and register the HttpModule in
the web.config file. That should allow you to provide the functionality
without modifying the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top