forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignalContainer.cs
More file actions
30 lines (25 loc) · 751 Bytes
/
Copy pathSignalContainer.cs
File metadata and controls
30 lines (25 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
namespace System.Web.Mvc.Async.Test
{
public sealed class SignalContainer<T>: IDisposable
{
private volatile object _item;
private readonly AutoResetEvent _waitHandle = new AutoResetEvent(false /* initialState */);
public void Signal(T item)
{
_item = item;
_waitHandle.Set();
}
public T Wait()
{
_waitHandle.WaitOne();
return (T)_item;
}
public void Dispose()
{
_waitHandle.Dispose();
}
}
}