/////////////////////////////////////////////////////////////////////// public static void CleanupSynchronized( Result synchronizedResult ) { if (synchronizedResult != null) { lock (synchronizedResult) { // // NOTE: Grab the client data (the event wait handle). // IClientData clientData = synchronizedResult.ClientData; if (clientData != null) { EventWaitHandle @event = clientData.Data as EventWaitHandle; if (@event != null) { ThreadOps.CloseEvent(ref @event); } } } } }
/////////////////////////////////////////////////////////////////////// public static bool WaitSynchronized( Result synchronizedResult, int milliseconds ) { EventWaitHandle @event = null; if (synchronizedResult != null) { lock (synchronizedResult) { // // NOTE: Grab the client data (the event wait handle). // IClientData clientData = synchronizedResult.ClientData; if (clientData != null) { @event = clientData.Data as EventWaitHandle; } } } if (@event != null) { return(ThreadOps.WaitEvent(@event, milliseconds)); } return(false); }
/////////////////////////////////////////////////////////////////////// #region Result Handling Methods #region Synchronized Methods public static Result CreateSynchronized( string name ) { Result synchronizedResult = String.Empty; /* FORCE VALID */ synchronizedResult.ClientData = new ClientData(ThreadOps.CreateEvent(name)); return(synchronizedResult); }
/////////////////////////////////////////////////////////////////////// public static void SetSynchronized( Result synchronizedResult, ReturnCode code, Result result ) { // // NOTE: Does the caller want to be notified about the result? // if (synchronizedResult != null) { lock (synchronizedResult) { // // NOTE: Grab the original client data (the event wait // handle). // IClientData clientData = synchronizedResult.ClientData; // // NOTE: Set the new client data (the result pair). // synchronizedResult.ClientData = new ClientData( new AnyPair <ReturnCode, Result>(code, result)); // // NOTE: If the original client data is valid and can be // cast to an event wait handle, signal it now. // if (clientData != null) { EventWaitHandle @event = clientData.Data as EventWaitHandle; if (@event != null) { /* IGNORED */ ThreadOps.SetEvent(@event); } } } } }