/// <summary> /// Starts the associated workflow. /// </summary> /// <param name="args">The workflow arguments.</param> /// <returns>The <see cref="WorkflowExecution"/>.</returns> public async Task <WorkflowExecution> StartAsync(params object[] args) { await SyncContext.Clear; Covenant.Requires <ArgumentNullException>(args != null, nameof(args)); EnsureNotStarted(); var argBytes = TemporalHelper.ArgsToBytes(client.DataConverter, args); Execution = await client.StartWorkflowAsync(WorkflowTypeName, argBytes, Options); return(Execution); }
/// <summary> /// Starts the workflow, returning an <see cref="IAsyncFuture"/> that can be used /// to wait for the the workflow to complete. This version does not return a workflow /// result. /// </summary> /// <param name="args">The workflow arguments.</param> /// <returns>An <see cref="ExternalWorkflowFuture"/> that can be used to retrieve the workflow result as an <c>object</c>.</returns> /// <exception cref="InvalidOperationException">Thrown if the workflow has already been started.</exception> /// <remarks> /// <note> /// <b>IMPORTANT:</b> You need to take care to ensure that the parameters passed /// are compatible with the target workflow method. /// </note> /// </remarks> public async Task <ExternalWorkflowFuture> StartAsync(params object[] args) { await SyncContext.Clear; Covenant.Requires <ArgumentNullException>(args != null, nameof(args)); if (execution != null) { throw new InvalidOperationException("Cannot start a future stub more than once."); } execution = await client.StartWorkflowAsync(workflowTypeName, TemporalHelper.ArgsToBytes(client.DataConverter, args), options); // Create and return the future. return(new ExternalWorkflowFuture(client, execution, options.Namespace)); }