Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Concurrent<T> {
- private ManualResetEvent _resetEvent;
- private T _result;
- public Concurrent(Func<T> f) {
- ThreadPool.QueueUserWorkItem(_ => {
- _result = f();
- IsCompleted = true;
- if (_resetEvent != null)
- _resetEvent.Set();
- });
- }
- public WaitHandle WaitHandle {
- get {
- if (_resetEvent == null)
- _resetEvent = new ManualResetEvent(IsCompleted);
- return _resetEvent;
- }
- public bool IsCompleted {get; private set;}
- ...
Add Comment
Please, Sign In to add comment