The Monitor class is waiting on the queue object with a timeout of 1000
milliseconds.
This thread and some other(s) are synchronised on the queue object.
From MSDN...
When a thread calls Wait, it releases the lock on the object and enters the
object's waiting queue. The next thread in the object's ready queue (if
there is one) acquires the lock and has exclusive use of the object. The
thread that invoked Wait remains in the waiting queue until either a thread
that holds the lock invokes PulseAll, or it is the next in the queue and a
thread that holds the lock invokes Pulse. However, if millisecondsTimeout
elapses before another thread invokes this object's Pulse or PulseAll
method, the original thread is moved to the ready queue in order to regain
the lock. If the condition in the object's state has not been met, the
thread might call Wait again to reenter the waiting queue until it has been
met.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Zach" <no*@this.address> wrote in message
news:ce***************************@freeler.nl...
Could someone please explain what the
consequence of this //****** line is?
public void SecondThread()
{
lock(m_smplQueue)
{
Monitor.Pulse(m_smplQueue);
while(Monitor.Wait(m_smplQueue,1000))//******
{
int counter = (int)m_smplQueue.Dequeue();
Console.WriteLine(counter.ToString());
Monitor.Pulse(m_smplQueue);
}
}
}