About Threads and Shared Methods ???

Discussion in 'ASP .Net' started by Gilles Lambert, Apr 26, 2004.

  1. Hi,

    I'm not sure about the folowing :

    If a shared method writes lines in a text file with a StreamWriter
    object during a request, is it possible to have several access
    interlaced to the file coming from different request ?

    If the answer is yes, is it the same with a general procedure (I guess
    yes but i'm not sure). So, in this case, what would be the best : using
    a mutex, opening the file in a exclusive way or anything else ?

    Thanks and best regards
    Gilles

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Gilles Lambert, Apr 26, 2004
    #1
    1. Advertising

  2. as a general rule, objects are not threadsafe which means they will need to
    be protected thru locking or use of the monitor class. Most static
    methods/properties are threadsafe (consult the docs to be absolutely
    certain). Without locking, the results are truly undetermined ranging from
    failed code in win < 2000, to garbled, interlaced text on NT systems. Have a
    look at the monitor class, it encapsulates thread protection.

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Gilles Lambert" <> wrote in message
    news:...
    > Hi,
    >
    > I'm not sure about the folowing :
    >
    > If a shared method writes lines in a text file with a StreamWriter
    > object during a request, is it possible to have several access
    > interlaced to the file coming from different request ?
    >
    > If the answer is yes, is it the same with a general procedure (I guess
    > yes but i'm not sure). So, in this case, what would be the best : using
    > a mutex, opening the file in a exclusive way or anything else ?
    >
    > Thanks and best regards
    > Gilles
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Alvin Bruney [MVP], Apr 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    3
    Views:
    16,112
    Gandalf
    Feb 8, 2004
  2. Joe Fallon
    Replies:
    3
    Views:
    761
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  3. ben
    Replies:
    3
    Views:
    508
    Kevin Spencer
    Nov 15, 2004
  4. HmFireBall
    Replies:
    2
    Views:
    514
    HmFireBall
    Jan 2, 2006
  5. Kenneth McDonald
    Replies:
    5
    Views:
    311
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page