public ActionToken ExecuteAsync(IActionItem actionCase) { var action = actionCase as ActionBase; ActionToken ret = null; if (action != null) { if (!SuppressDebugOutput) { "{0:X2} (E){1}"._DLOG(SessionId, action.GetName() + action.AboutMeSafe()); } if (action.Token != null) { action.Token.HandleMe = (x) => OnHandleToken(x); action.Token.LogEntryPointClassLineNumber = GetLineNumberInTheEntryPointClass(LogEntryPointClass); action.Token.StartSignal = _actionStartSignal; } ret = action.Token; ActionCaseConsumer.Add(action); if (!isDisposing) { //_actionStartSignal.WaitOne(1000); if (!SuppressDebugOutput) { "{0:X2} (R){1}"._DLOG(SessionId, action.GetName() + action.AboutMeSafe()); } } } return(ret); }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { isDisposing = true; // TODO: dispose managed state (managed objects). _actionStartSignal.Set(); _actionStartSignal.Close(); CallbackBufferBlock.Stop(); TimeoutManager.Stop(); ActionCaseConsumer.Stop(); RunningActions.ForEach(action => { action.Token.SetCancelled(); action.Token.SetCompletedSignal(); return(false); }); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
public void OnHandleToken(ActionToken actionToken) { RunningActions.ForEach(action => { if (action.Token == actionToken) { ActionCaseConsumer.Add(action); } return(false); }); }
public void RunComponents() { TimeoutManager.Start(this); CallbackBufferBlock.Start("CallbackBufferBlock", action => { if (action.CompletedCallback != null) { action.CompletedCallback(action); } }); ActionCaseConsumer.Start("ActionCaseConsumer", HandleActionCaseInner); }
public void Cancel(Type actionType) { RunningActions.ForEach(type => { if (type.GetType() == actionType) { type.Token.SetCancelling(); ActionCaseConsumer.Add(type); } return(false); }); }
public void TokenExpired(ActionToken actionToken) { RunningActions.ForEach(action => { if (action.Token == actionToken) { action.Token.SetExpiring(); ActionCaseConsumer.Add(action); } return(false); }); }
public void Cancel(ActionToken actionToken) { if (actionToken != null && !actionToken.IsStateFinished) { RunningActions.ForEach(action => { if (action.Token == actionToken) { action.Token.SetCancelling(); ActionCaseConsumer.Add(action); } return(false); }); } }
public void HandleActionCase(IActionCase actionCase) { var dataFrame = actionCase as CustomDataFrame; var timeInterval = actionCase as TimeInterval; if (dataFrame != null && !dataFrame.IsOutcome && !dataFrame.IsHandled) { if (IsHandleFrameEnabled) { ActionCaseConsumer.Add(dataFrame); } } if (timeInterval != null && !timeInterval.IsHandled) { ActionCaseConsumer.Add(timeInterval); } }
public void ProcessNext(ActionHandlerResult ahResult) { if (ahResult != null && ahResult.NextActions != null) { var sendFrames = ahResult.NextActions.Where(x => x is CommandMessage); var timeIntervals = ahResult.NextActions.Where(x => x is TimeInterval); var actions = ahResult.NextActions.Where(x => x is ActionBase); if (sendFrames.Any()) { if (SendFramesCallback != null) { var isTransmitted = SendFramesCallback(ahResult); if (isTransmitted) { ahResult.Parent.FixStates(); } else { ahResult.Parent.Token.SetFailed(); } if (ahResult.Parent.Token.IsStateFinished) { ActionCaseConsumer.Add(ahResult.Parent); } } } if (timeIntervals.Any()) { foreach (TimeInterval item in timeIntervals) { TimeoutManager.AddTimer(item); } } if (actions.Any()) { foreach (ActionBase item in actions) { ActionCaseConsumer.Add(item); } } } }
private void ProcessCompleted(ActionBase action) { if (action.Token.IsStateFinished) { if (RunningActions.Remove(action)) { action.Token.Name = action.Name + ": " + action.AboutMeSafe(); if (_actionChangeCallback != null) { _actionChangeCallback(action.Token); } action.Token.SetCompletedSignal(); if (!SuppressDebugOutput) { "{0:X2} {1}"._DLOG(SessionId, action.GetName() + action.AboutMeSafe()); } CallbackBufferBlock.Add(action); ActionCaseConsumer.Add(action); } } }