Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > About Threads and Shared Methods ???

Reply
Thread Tools

About Threads and Shared Methods ???

 
 
Gilles Lambert
Guest
Posts: n/a
 
      04-26-2004
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!
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      04-26-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
How far are "Shared" objects and properties shared? HmFireBall ASP .Net 2 01-02-2006 01:02 PM
Shared, why not a 'Local Shared' (re: Session and ViewState dislike) ben ASP .Net 3 11-15-2004 03:04 PM
Shared Public Variables and Shared Methods Joe Fallon ASP .Net 3 07-16-2004 07:11 AM
Question about threads::shared and blessed references Nick Marden Perl 0 01-17-2004 05:16 AM



Advertisments