Home > Net >  C # BlockingCollection TryTake anomalies
C # BlockingCollection TryTake anomalies

Time:01-21

Environment of the.net framework 4.5, WPF project types,


Empty set before TryTake
Public static void Clear (BlockingCollection BlockingCollection)
{
If (blockingCollection==null)
{
return;
}
While (blockingCollection. Count & gt; 0)
{
BlockingCollection. Take ();
}
}

Then _queue. TryTake (the out Frame Frame, a timeout, the source. The Token). Thread id 3
Set the timeout here 35000.


In the other thread _queue. Add (frame); The thread id 6

Oddly TryTake take a value until no overtime,

Ps:
In _queue. Add (frame); Take in the thread, can Take to the value,
V, in _queue. Add (frame); Where the thread is executed after the add to take can be taken to the value of,

Please help to analyze reasons.



  •  Tags:  
  • C#
  • Related