/// <summary> /// Signals the workflow. /// </summary> /// <param name="signalName">The signal name.</param> /// <param name="args">The signal arguments.</param> /// <returns>The tracking <see cref="Task"/>.</returns> /// <exception cref="InvalidOperationException">Thrown if the child workflow has not 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 signal arguments. /// </note> /// </remarks> public async Task SignalAsync(string signalName, params object[] args) { await SyncContext.Clear; Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(signalName), nameof(signalName)); Covenant.Requires <ArgumentNullException>(args != null, nameof(args)); if (Execution == null) { throw new InvalidOperationException("The stub must be started first."); } var reply = await parentWorkflow.ExecuteNonParallel( async() => { return((WorkflowSignalChildReply)await client.CallProxyAsync( new WorkflowSignalChildRequest() { ContextId = parentWorkflow.ContextId, ChildId = childExecution.ChildId, SignalName = signalName, SignalArgs = TemporalHelper.ArgsToBytes(client.DataConverter, args) })); }); reply.ThrowOnError(); }
/// <summary> /// Signals the workflow. /// </summary> /// <param name="signalName"> /// The signal name as defined by the <see cref="SignalMethodAttribute"/> /// decorating the workflow signal method. /// </param> /// <param name="args">The signal arguments.</param> /// <returns>The tracking <see cref="Task"/>.</returns> /// <exception cref="InvalidOperationException">Thrown if the child workflow has not 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 arguments. No compile-time type checking /// is performed for this method. /// </note> /// </remarks> public async Task SignalAsync(string signalName, params object[] args) { await SyncContext.Clear; Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(signalName), nameof(signalName)); Covenant.Requires <ArgumentNullException>(args != null, nameof(args)); if (execution == null) { throw new InvalidOperationException("The stub must be started first."); } var reply = (WorkflowSignalReply)await client.CallProxyAsync( new WorkflowSignalRequest() { WorkflowId = execution.WorkflowId, RunId = execution.RunId, Namespace = options.Namespace, SignalName = signalName, SignalArgs = TemporalHelper.ArgsToBytes(client.DataConverter, args) }); reply.ThrowOnError(); }