mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 07:01:18 +03:00
Changed Monitor.TryEnter(...) to lock(...) {}
This commit is contained in:
@@ -163,25 +163,24 @@ namespace Amib.Threading.Internal
|
||||
int millisecondsTimeout,
|
||||
WaitHandle cancelEvent)
|
||||
{
|
||||
// This method cause the caller to wait for a work item.
|
||||
// If there is at least one waiting work item then the
|
||||
// method returns immidiately with it.
|
||||
//
|
||||
// If there are no waiting work items then the caller
|
||||
// is queued between other waiters for a work item to arrive.
|
||||
//
|
||||
// If a work item didn't come within millisecondsTimeout or
|
||||
// the user canceled the wait by signaling the cancelEvent
|
||||
// then the method returns null to indicate that the caller
|
||||
// didn't get a work item.
|
||||
// This method cause the caller to wait for a work item.
|
||||
// If there is at least one waiting work item then the
|
||||
// method returns immidiately with it.
|
||||
//
|
||||
// If there are no waiting work items then the caller
|
||||
// is queued between other waiters for a work item to arrive.
|
||||
//
|
||||
// If a work item didn't come within millisecondsTimeout or
|
||||
// the user canceled the wait by signaling the cancelEvent
|
||||
// then the method returns null to indicate that the caller
|
||||
// didn't get a work item.
|
||||
|
||||
WaiterEntry waiterEntry;
|
||||
WorkItem workItem = null;
|
||||
WaiterEntry waiterEntry;
|
||||
WorkItem workItem = null;
|
||||
|
||||
try
|
||||
lock (this)
|
||||
{
|
||||
while (!Monitor.TryEnter(this)) { }
|
||||
//Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
//Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
//Monitor.Enter(this);
|
||||
//stopwatch.Stop();
|
||||
|
||||
@@ -202,10 +201,6 @@ namespace Amib.Threading.Internal
|
||||
// Put the waiter with the other waiters
|
||||
PushWaiter(waiterEntry);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(this);
|
||||
}
|
||||
|
||||
// Prepare array of wait handle for the WaitHandle.WaitAny()
|
||||
WaitHandle [] waitHandles = new WaitHandle[] {
|
||||
|
||||
Reference in New Issue
Block a user