471,338 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

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

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
Jul 21 '05 #1
3 1896
Robb,

How did you made it multithreaded?

Cor
Jul 21 '05 #2
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

"Cor Ligthert" wrote:
Robb,

How did you made it multithreaded?

Cor

Jul 21 '05 #3
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.

Robb Gilmore wrote:
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

"Cor Ligthert" wrote:

Robb,

How did you made it multithreaded?

Cor

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sherif ElMetainy | last post: by
5 posts views Thread by toddles666 | last post: by
reply views Thread by Gordon Cone | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.