Skip to main content

Introducing Formengine - The New Formbuilder, try for FREE formengine.io.

Workflow Engine 2.2

  • Now it is possible to create asynchronous Actions and Conditions. You can call asynchronous methods from Actions and Conditions using the await keyword. Such methods will be the most effective if you use asynchronous methods of the WorkflowRuntime object, for example, ExecuteCommandAsync instead of ExecuteCommand, or SetStateAsync instead of SetState, etc. You can create asynchronous Actions in Designer. To do that you simply need to check the Async checkbox in the Action or Condition where you're going to call asynchronous methods from. If you use IWorkflowActionProvider, then you will need to implement 4 additional methods. bool IsActionAsync(string name) and bool IsConditionAsync(string name) should return true so that the Action or Condition are called asynchronously. The execution of an asynchronous Action or Condition is done in the Task ExecuteActionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token) and Task<bool> ExecuteConditionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token) methods.
  • Parameters conveyed to the process with the command no longer need to be described as command parameters. If such a parameter is described in the scheme, it will be a Temporary or a Persistence one, depending on which Purpose is specified in the scheme. If the parameter is not described in the scheme, it will be a Temporary one.
  • The ExecuteCommand and ExecuteCommandAsync methods return information on whether the command has been executed (it may not be executed under certain conditions) and the ProcessInstance state after the execution of a command.

The following additional actions must be taken to upgrade to Workflow Engine 2.2:

  • If you use IWorkflowActionProvider, you will need to add 4 new methods to it: IsActionAsync, IsConditionAsync, ExecuteActionAsync, ExecuteConditionAsync. If you do not yet intend to use asynchronous Actions, then the IsActionAsync and IsConditionAsync methods should always return false, whereas ExecuteActionAsync and ExecuteConditionAsync can throw a NotImplementedException.
public bool IsActionAsync(string name)
{
return false;
}

public bool IsConditionAsync(string name)
{
return false;
}

public async Task ExecuteActionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token)
{
throw new NotImplementedException();
}

public async Task<bool> ExecuteConditionAsync(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter, CancellationToken token)
{
throw new NotImplementedException();
}