Example #1
0
        public async Task DisposeAsync()
        {
            Stop?.Cancel();
            await ReconnectorTask.ConfigureAwait(false);

            Disconnect();
            Stop?.Dispose();
            Stop = null;
        }
Example #2
0
 private void CancelExit()
 {
     // reset the bar counter and cancel the trailing stop
     barsFromEntry = 0;
     if (trailingStop != null)
     {
         trailingStop.Cancel();
     }
 }
 public async Task StopAsync()
 {
     Interlocked.CompareExchange(ref _running, 2, 1);             // If running, make it stopping.
     Stop?.Cancel();
     while (IsStopping)
     {
         await Task.Delay(50);
     }
     Stop?.Dispose();
 }
Example #4
0
 public async Task StopAsync()
 {
     if (IsRunning)
     {
         Interlocked.Exchange(ref _running, 2);
     }
     Stop?.Cancel();
     while (IsStopping)
     {
         await Task.Delay(50);
     }
     Stop?.Dispose();
 }
Example #5
0
        private volatile bool _disposedValue = false;         // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    Stop?.Cancel();
                    Disconnect();
                    Stop?.Dispose();
                    Stop = null;
                }

                _disposedValue = true;
            }
        }
Example #6
0
    public async Task DisposeAsync()
    {
        if (_disposed)
        {
            return;
        }
        _disposed = true;

        Stop.Cancel();

        await P2pReconnector.StopAsync(CancellationToken.None).ConfigureAwait(false);

        P2pReconnector.Dispose();

        await TryDisconnectAsync(CancellationToken.None).ConfigureAwait(false);

        Stop.Dispose();
    }
Example #7
0
        private volatile bool _disposedValue = false;         // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    Interlocked.CompareExchange(ref _running, 2, 1);                     // If running, make it stopping.
                    Stop?.Cancel();
                    while (IsStopping)
                    {
                        Task.Delay(50).GetAwaiter().GetResult();
                    }
                    Stop?.Dispose();
                }

                _disposedValue = true;
            }
        }