// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Threading { using System; using System.Runtime.CompilerServices; using Microsoft.Singularity; using Microsoft.Singularity.V1.Threads; using Microsoft.Singularity.V1.Services; //| [CLSCompliant(false)] public sealed class ManualResetEvent : WaitHandle { private ManualResetEventHandle handle; //| public ManualResetEvent(bool initialState) { ManualResetEventHandle handleOnStack; if (!ManualResetEventHandle.Create(initialState, out handleOnStack)) { throw new HandleCreateException(); } handle = handleOnStack; } /// /// Finalizer is responsible for freeing handle that keeps corresponding /// kernel object live. /// ~ManualResetEvent() { if (this.handle.id != 0) { ManualResetEventHandle.Dispose(this.handle); this.handle = new ManualResetEventHandle(); } } //| public void Reset() { ManualResetEventHandle.Reset(handle); GC.KeepAlive(this); } //| public bool Set() { bool b = ManualResetEventHandle.Set(handle); GC.KeepAlive(this); return b; } protected override SyncHandle Handle{ get { return handle; } } //| public override bool WaitOne(TimeSpan timeout) { bool b = SyncHandle.WaitOne(handle, timeout); GC.KeepAlive(this); return b; } //| public override bool WaitOne(SchedulerTime stop) { bool b = SyncHandle.WaitOne(handle, stop); GC.KeepAlive(this); return b; } //| public override bool WaitOne() { bool b = SyncHandle.WaitOne(handle); GC.KeepAlive(this); return b; } //| protected override void Dispose(bool explicitDisposing) { if (handle.id != 0) { ManualResetEventHandle.Dispose(handle); handle = new ManualResetEventHandle(); } } } }