Beispiel #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public SignalRequest()
        {
            // This class may only be constructed within signal or workflow methods.

            WorkflowBase.CheckCallContext(allowSignal: true, allowWorkflow: true);

            SignalId = Workflow.Current.SignalId;
        }
Beispiel #2
0
        /// <summary>
        /// Releases all associated resources.
        /// </summary>
        /// <param name="disposing">Pass <c>true</c> if we're disposing, <c>false</c> if we're finalizing.</param>
        protected virtual void Dispose(bool disposing)
        {
            WorkflowBase.CheckCallContext(allowWorkflow: true, allowSignal: true);

            if (disposing && !isClosed)
            {
                CloseAsync().WaitWithoutAggregate();
            }

            isDisposed = true;
        }
Beispiel #3
0
        /// <summary>
        /// Internal constructor.
        /// </summary>
        /// <param name="parentWorkflow">The parent workflow.</param>
        /// <param name="queueId">The queue ID.</param>
        /// <param name="capacity">The maximum number of items allowed in the queue.</param>
        /// <exception cref="NotSupportedException">Thrown when this is called outside of a workflow entry point method.</exception>
        /// <remarks>
        /// <note>
        /// <see cref="WorkflowQueue{T}"/> instances may only be created within
        /// workflow entry point methods.
        /// </note>
        /// </remarks>
        internal WorkflowQueue(Workflow parentWorkflow, long queueId, int capacity)
        {
            Covenant.Requires <ArgumentNullException>(parentWorkflow != null, nameof(parentWorkflow));
            Covenant.Requires <ArgumentException>(queueId > 0, nameof(queueId));
            Covenant.Requires <ArgumentException>(capacity >= 2, nameof(capacity));
            WorkflowBase.CheckCallContext(allowWorkflow: true);

            this.client    = parentWorkflow.Client;
            this.contextId = parentWorkflow.ContextId;
            this.Capacity  = capacity;
            this.queueId   = queueId;
            this.isClosed  = false;
        }
Beispiel #4
0
        /// <summary>
        /// Called by your workflow logic to indicate that processing for the synchronous
        /// signal is complete as well as specifying the signal result.
        /// </summary>
        /// <param name="result">The value to be returned by the signal.</param>
        /// <returns>The tracking <see cref="Task"/>.</returns>
        public async Task ReplyAsync(TResult result)
        {
            await SyncContext.Clear;

            // This may only be called within a workflow method.

            WorkflowBase.CheckCallContext(allowWorkflow: true);

            // Save the signal completion and result so a subsequent polling query can retrieve it.

            SignalStatus.Result    = Workflow.Current.Client.DataConverter.ToData(result);
            SignalStatus.Completed = true;

            await Task.CompletedTask;
        }
Beispiel #5
0
        /// <summary>
        /// Called by your workflow logic to indicate that processing for the synchronous
        /// signal is complete.  This method also waits for a period of time before
        /// returning to help ensure that the signal result can be delivered back to
        /// the calling client before the workflow terminates.
        /// </summary>
        /// <returns>The tracking <see cref="Task"/>.</returns>
        public async Task ReplyAsync()
        {
            await SyncContext.Clear;

            // This may only be called within a workflow method.

            WorkflowBase.CheckCallContext(allowWorkflow: true);

            // Save the signal completion so a subsequent polling query can retrieve it.

            SignalStatus.Result    = null;  // NULL result for void signal methods
            SignalStatus.Completed = true;

            await Task.CompletedTask;
        }