public class AsyncObjectWait<T1, TriggerType>
{
private Queue<TaskCompletionSource<TriggerType>> _waits;
T1 _value;
public AsyncObjectWait(T1 triggerValue)
{
_value = triggerValue;
_waits = new Queue<TaskCompletionSource<TriggerType>>();
}
private void _timeout(TimeSpan timeout, TaskCompletionSource<TriggerType> tcs)
{
System.Threading.Thread.Sleep(timeout);
lock (tcs)
{
if (!tcs.TrySetException(new TimeoutException("Wait Timed Out")))