c# lock

  • Thread starter Thread starter Nalaka
  • Start date Start date
N

Nalaka

Hi,
I need to code so that only one thread can do a piece of work... other
threads need not do the work if a thread is alredy doing the work.

something like this.....

if ( isAlreadyLocked )
{ return anotherThreadIsAlredyAtWork }

lock ( myObject )
{
// do the work
}


Any help is appreciated
Thanks
Nalaka
 
aaah sorry Nicholas,
I am using outLook express to look at this thread... it does not show my
yesterday's post.
I thought my yestreday's post did not go through... thats why I posted
again.

sorry again
Nalaka



Nicholas Paldino said:
What was wrong with the previous answers?

http://groups.google.com/group/micr...holas+Paldino+c#+lock&rnum=2#3928a655441147c5


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nalaka said:
Hi,
I need to code so that only one thread can do a piece of work... other
threads need not do the work if a thread is alredy doing the work.

something like this.....

if ( isAlreadyLocked )
{ return anotherThreadIsAlredyAtWork }

lock ( myObject )
{
// do the work
}


Any help is appreciated
Thanks
Nalaka
 

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

Back
Top