Do compiled library dll's in ASP.NEt need to be thread safe?

J

jpatrcik

Don't see any official notice that compiled library dll's loaded in the BIN
directory of an asp.net website need to be thread safe, but concurrent visits
to the same web site sure bear this out. Does anyone know the answer to this?
 
T

Teemu Keiski

Hi,

you need to also understand that in ASP.NET page and control objects are
instantiated for every request, so thread safety is to consider when you
deal with global variables like static variables, cache etc. Within single
page, in real world, you need thread safety less than you might think.
ASP.NET is designed to avoid this need because writing good, thread-safe
code is actually pretty demanding.

See: http://msdn.microsoft.com/en-us/magazine/cc163929.aspx
 
G

George Ter-Saakov

There is no such thing a "thread safe compiled DLL".
Only code can be thread safe or not safe. And if you compile thread safe
code into DLL then it's going to be thread safe DLL (if you want to say
that)

Considering that you writing a code for DLLs that end up in BIN folder your
question is not making sense as it is.....

If you talking about standard .NET library then it's well documented in
MSDN which classes/methods are thread safe and which are not.
Mostly they all not thread safe.... But keep in mind that .NET serializes
request to the same Session. Meaning if one browser sent 2 requests then
second request will execute only when first request has finished. Different
people will get different Sessions so one person will not wait till first
request ends.


George.
 
B

bruce barker

there are several levels of thread safe.

1) whether the code supports multiple threaded applications. all .net code
supports this, but not all c code.

then for objects:

2) can a object created on thread be accessed by another thread. (vb6 com
objects are an example where this can not be done safely).

3) if the object allows above, can two threads access it at the same time.
in the .net docs, this is what is meant by thread safe. some of the .net
runtime is, and some isn't.

for asp.net, #2 is required. the only exception is sta (vb6) com objects.
for sta com objects, aspcompat must be set. to handle this case asp.net
creates the com object on a single thread, and all calls are proxied (made)
from that thread.


-- bruce (sqlwork.com)
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top