Use CriticalSection to prevent deadlocks on dequeue