/// <summary> /// Specifies the action to be called on entering the currently configured state. /// This overload is used to provide non-blocking async action. /// </summary> /// <remarks>Do not use async void methods, async methods should return <see cref="Task"/></remarks> public Exit OnEnter(Func <IStateMachine <TEvent>, Task> enterAction) { if (enterAction is null) { throw new ArgumentNullException(nameof(enterAction)); } EnterActionInvoker = EnterActionInvokerFactory <TEvent> .Create(enterAction); return(this); }
/// <summary> /// Specifies the action to be called on entering the currently configured state. /// This overload is used to provide blocking action. To provide async action use <see cref="OnEnter(Func{IStateMachine{TEvent}, Task})"/>. /// </summary> /// <remarks>Do not use async void methods, async methods should return <see cref="Task"/></remarks> public Exit OnEnter(Action <IStateMachine <TEvent> > enterAction) { if (enterAction is null) { throw new ArgumentNullException(nameof(enterAction)); } if (IsAsyncMethod(enterAction.Method)) { throw new ArgumentException(AsyncVoidMethodNotSupported); } EnterActionInvoker = EnterActionInvokerFactory <TEvent> .Create(enterAction); return(this); }