// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================================= ** ** Class: WaitHandle (this name is NOT definitive) ** ** ** Purpose: Class to represent all synchronization objects in the runtime (that allow multiple wait) ** ** Date: August, 1999 ** =============================================================================*/ namespace System.Threading { using System; using System.Threading; using System.Runtime.CompilerServices; using System.Collections; using Microsoft.Singularity; using Microsoft.Singularity.V1.Threads; using Microsoft.Singularity.V1.Services; //| [CLSCompliant(false)] public abstract class WaitHandle : IDisposable { //| public const int WaitTimeout = -1; protected WaitHandle() { } protected abstract SyncHandle Handle{ get; } //| public abstract bool WaitOne(TimeSpan timeout); //| public abstract bool WaitOne(SchedulerTime stop); [Obsolete("Do not use DateTime for scheduling. It is meaningless. Use SchedulerTime")] public bool WaitOne(DateTime stop) { SchedulerTime st = SchedulerTime.MinValue + (stop - DateTime.BootTime); return WaitOne(st); } //| public abstract bool WaitOne(); //| public static unsafe int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout) { SyncHandle[] handles = Thread.CurrentThread.GetSyncHandles(waitHandles.Length); for (int i = 0; i < waitHandles.Length; i++) { handles[i] = waitHandles[i].Handle; } fixed (SyncHandle *array = &handles[0]) { return SyncHandle.WaitAny(array, waitHandles.Length, timeout); } } //| public static unsafe int WaitAny(WaitHandle[] waitHandles, SchedulerTime stop) { SyncHandle[] handles = Thread.CurrentThread.GetSyncHandles(waitHandles.Length); for (int i = 0; i < waitHandles.Length; i++) { handles[i] = waitHandles[i].Handle; } fixed (SyncHandle *array = &handles[0]) { return SyncHandle.WaitAny(array, waitHandles.Length, stop); } } //| public static unsafe int WaitAny(WaitHandle[] waitHandles) { SyncHandle[] handles = Thread.CurrentThread.GetSyncHandles(waitHandles.Length); for (int i = 0; i < waitHandles.Length; i++) { handles[i] = waitHandles[i].Handle; } fixed (SyncHandle *array = &handles[0]) { return SyncHandle.WaitAny(array, waitHandles.Length); } } //| protected abstract void Dispose(bool explicitDisposing); //| public virtual void Close() { Dispose(true); GC.nativeSuppressFinalize(this); } //| /// void IDisposable.Dispose() { Dispose(true); GC.nativeSuppressFinalize(this); } //| ~WaitHandle() { Dispose(false); } } }