public CommandTaskProcess(Func <CancellationToken, bool> task) { m_Activation = async() => { if (m_TokenSource != null) { iStop(); // restart if running } m_TokenSource = new CancellationTokenSource(); // run task var token = m_TokenSource.Token; var result = await Task.Run(() => task(token), token); // could be complete of iStop if (m_TokenSource != null) { // clear data m_TokenSource.Dispose(); m_TokenSource = null; // notify commandValidator if (result) { m_Validator.iSucceeded(this); } else { m_Validator.iFailed(this); } } }; }
public CommandTask(Func <bool> task) { m_Activation = async() => { var result = await Task.Run(task); // notify commandValidator if (result) { m_Validator.iSucceeded(this); } else { m_Validator.iFailed(this); } }; }
public void iFailed(ICommand command) { OnFailed?.Invoke(); m_TaskHandle.iFailed(command); }
public void iFailed(ICommand command) { m_CommandValidator.iFailed(command); }
////////////////////////////////////////////////////////////////////////// public void iStart(ICommandValidator validator) { validator.iFailed(this); }
////////////////////////////////////////////////////////////////////////// public void iStart(ICommandValidator validator) { Debug.Log("Failed"); validator.iFailed(); }
public void iFailed() { m_State = State.Failed; m_CommandNotifier.iFailed(m_CurrentCommand.Value); m_CommandValidator?.iFailed(); }
public void iFailed() { OnFailed?.Invoke(); m_TaskHandle.iFailed(); }