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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?anBhdHJjaWs=?=

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

    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?
  • Teemu Keiski

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

    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

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP




    "jpatrcik" <jpatrcik@discu ssions.microsof t.comwrote in message
    news:4A00BB49-E58D-4655-87D7-DFE62F5A3878@mi crosoft.com...
    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?

    Comment

    • George Ter-Saakov

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

      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.


      "jpatrcik" <jpatrcik@discu ssions.microsof t.comwrote in message
      news:4A00BB49-E58D-4655-87D7-DFE62F5A3878@mi crosoft.com...
      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?

      Comment

      • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

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

        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)


        "jpatrcik" wrote:
        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?

        Comment

        Working...