Ejemplo n.º 1
0
        /// <summary>
        /// Confirm the request
        /// </summary>
        /// <param name="tcs">Confirm task completion source</param>
        internal void ConfirmRequest(ConfirmTaskCompletionSource tcs)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                tcs.SetCanceled();
            }

            lock (confirmTaskLock)
            {
                currentTaskSource = tcs;
            }

            try
            {
                bool result = ConfirmWriter(string.Empty, tcs.Message, Resources.ConfirmCaption);
                tcs.SetResult(result);
            }
            catch (Exception e)
            {
                tcs.SetException(e);
            }

            lock (confirmTaskLock)
            {
                currentTaskSource = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cancel the confirmation request
        /// </summary>
        public void CancelConfirmRequest()
        {
            ConfirmTaskCompletionSource tcs = null;

            while (ConfirmQueue.Value.TryDequeue(out tcs))
            {
                tcs.SetCanceled();
            }

            lock (confirmTaskLock)
            {
                if (currentTaskSource != null)
                {
                    currentTaskSource.SetCanceled();
                }

                currentTaskSource = null;
            }
        }