public void End()
        {
            if (Interlocked.Exchange(ref _ended, 1) == 0)
            {
                Trace.TraceInformation("End(" + ConnectionId + ")");

                if (_connectionEndTokenSource != null)
                {
                    _connectionEndTokenSource.Cancel();
                }

                if (_connectionEndTokenSource != null)
                {
                    _connectionEndTokenSource.Dispose();
                }

                _hostRegistration.Dispose();
            }
        }
示例#2
0
        /// <summary>
        /// Stops the <see cref="Connection"/> without sending an abort message to the server.
        /// </summary>
        public void Disconnect()
        {
            lock (_stateLock)
            {
                // Do nothing if the connection is offline
                if (State != ConnectionState.Disconnected)
                {
                    _disconnectTimeoutOperation.Dispose();
                    _disconnectCts.Cancel();
                    _disconnectCts.Dispose();
                    _disconnectCts = new SafeCancellationTokenSource();

                    State = ConnectionState.Disconnected;

                    // TODO: Do we want to trigger Closed if we are connecting?
                    if (Closed != null)
                    {
                        Closed();
                    }
                }
            }
        }
示例#3
0
 public void OnCompleted()
 {
     _logger.LogInformation($" -- GitHub monitoring complete. {_observedActivities.Count} activities observed.");
     _cancellationToken.Cancel(useNewThread: false);
 }