Exemple #1
0
        /// <summary>
        /// Enqueues a pause action onto the consumer thread's queue.
        /// Items currently in the queue execute before the thread is paused.
        /// A unique token is returned that can be used to resume the thread with a call to <see cref="Resume(ResetEventToken)"/>
        /// </summary>
        public ResetEventToken Pause()
        {
            ResetEventToken resetToken = new ResetEventToken();

            EnqueueAction((threadPauseEvent) => threadPauseEvent.Wait(), resetToken.resetEvent);
            return(resetToken);
        }
Exemple #2
0
        /// <summary>
        /// Enqueues a unique <see cref="ResetEventToken"/> that can be used to block the calling thread until the <see cref="ResetEventToken"/> has been dequeued.
        /// Call <see cref="WaitOnResetEventToken(ResetEventToken)"/> to wait until the <see cref="ResetEventToken"/> has been dequeued.
        /// </summary>
        public ResetEventToken EnqueueResetEventToken()
        {
            ResetEventToken resetToken = new ResetEventToken();

            EnqueueAction((resetEvent) => resetEvent.Set(), resetToken.resetEvent);
            return(resetToken);
        }
Exemple #3
0
 /// <summary>
 /// Uses the provided <see cref="ResetEventToken"/> to resume the thread from the point in the queue when it was paused.
 /// </summary>
 public void Resume(ResetEventToken pauseResetToken)
 {
     pauseResetToken.resetEvent.Reset();
 }
Exemple #4
0
 /// <summary>
 /// Waits until the provided <see cref="ResetEventToken"/> has been dequeued.
 /// </summary>
 public void WaitOnResetEventToken(ResetEventToken resetToken)
 {
     resetToken.resetEvent.Wait();
 }