示例#1
0
            /// <summary>
            /// Cancels the specified request.
            /// </summary>
            /// <param name="request">The request.</param>
            public void Cancel([NotNull] CommandCancelRequest request)
            {
                if (request == null)
                {
                    throw new ArgumentNullException("request");
                }
                _cancelRequest = request;
                ICancelableTokenSource cts = Interlocked.Exchange(ref _cancellationTokenSource, null);

                if (cts != null)
                {
                    cts.Cancel();
                    cts.Dispose();
                }
            }
示例#2
0
            /// <summary>
            /// Releases the unmanaged resources used by the <see cref="T:System.IO.TextWriter" /> and optionally releases the managed resources.
            /// </summary>
            /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
            protected override void Dispose(bool disposing)
            {
                ICancelableTokenSource cts = Interlocked.Exchange(ref _cancellationTokenSource, null);

                if (cts != null)
                {
                    cts.Cancel();
                    cts.Dispose();
                }

                NamedPipeConnection connection = Interlocked.Exchange(ref _connection, null);

                if (connection != null)
                {
                    connection.Remove(this);
                }

                base.Dispose(disposing);
            }