Check if resourse is locked

  • Thread starter Thread starter bg_ie
  • Start date Start date
B

bg_ie

Hi,

I have the following in my com object-

static public uint Time
{
get
{
lock (Channel.staticLockObject)
{
return Channel.time;
}
}

}

Sometimes though I am getting back incorrect values when using Time.
How can I check if Channel.staticLockObject is already locked so that I
can print a debug message?

Thanks for your help,

Barry.
 
Hello (e-mail address removed),

Intoduce new variable, in the scope of lock, and set it to true.
Another way is to lock via Monitor.Enter and use TryEnter to check whether
lock exists

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
 

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