public Buffer(bool readerWait) { this.writer = CreateWriter(); this.readerWait = readerWait; if (readerWait) { light = new LightObject(null, true, false, IntPtr.Zero, null); } }
protected override void ClearUnmanagedResources() { if (timeoutObserver != null) { timeoutObserver.Stop(); timeoutObserver = null; } if (light != null) { light.Dispose(); light = null; } }
/// <summary> /// 异步方式执行活动。 /// </summary> /// <param name="bWaitForComplete"></param> /// <returns></returns> public ActionExecuteResult AsyncExecute(bool bWaitForComplete) { try { ResetRuntimeData(); _state = ActionState.Processing; _activateTime = DateTime.Now; if (bWaitForComplete) { light = new LightObject(Guid.NewGuid().ToString("N"), false, false, IntPtr.Zero, null); InnerExecute(); WaitResult waitResult = light.Wait(_executeTimeout, false); if (waitResult == WaitResult.TimeOut) { ActionTimout(); } light.Dispose(); light = null; return new ActionExecuteResult(resultEventArgs, faultEventArgs); } else { if (_executeTimeout > 0) { this.timeoutObserver = new TimeoutObserver(); this.timeoutObserver.OnTick += new EventHandler(timeoutObserver_OnTick); this.timeoutObserver.Execute(_executeTimeout); } InnerExecute(); return null; } } catch (Exception ex) { Fault(ActionErrorCodes.UNKNOWN_ERROR, ex); if (bWaitForComplete) { return new ActionExecuteResult(resultEventArgs, faultEventArgs); } else { return null; } } }
public void Dispose() { if (light != null) { //ȡ��// Cancel(true); //�źŵ�����// light.Dispose(); light = null; } }