示例#1
0
 //private Lockable<bool> IsDisposed { get; } = new Lockable<bool>();
 /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
 protected virtual void OnDispose()
 {
     _mreWriteComplete?.Dispose();
     _mreWriteComplete = null;
     _thread?.Dispose();
     _thread = null;
 }
示例#2
0
 public void Stop()
 {
     lock (_lock)
     {
         if (_thread != null)
         {
             Mre.Set();
             _thread.Cancel();
             _thread.WaitForValue(t => t.IsRunning == false, 1000);
             _thread.Dispose();
             _thread = null;
         }
         Client?.Disconnect();
         Client = null;
     }
 }
示例#3
0
            public void Dispose()
            {
                if (_disposing.Value)
                {
                    return;
                }
                _disposing.Value = true;

                _thread.Dispose();
                Cancel();
                //_cts.Dispose();
                _mreCompleted?.Set();
                _mreCompleted?.Dispose();
                _mreCompleted = null;
                if (_genericClient != null)
                {
                    _genericClient.MessageReceived -= OnMessageReceived;
                }
                _genericClient = null;
                GC.SuppressFinalize(this);
            }