Exemplo n.º 1
0
        //dispose pattern as described on msdn for a class that uses a safe handle
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

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

            ClearEventSubscriptions();

            if (_toxAv != null && !_toxAv.IsInvalid && !_toxAv.IsClosed)
            {
                _toxAv.Dispose();
            }

            _disposed = true;
        }
Exemplo n.º 2
0
        //dispose pattern as described on msdn for a class that uses a safe handle
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
            }

            if (!toxav.IsInvalid && !toxav.IsClosed && toxav != null)
            {
                toxav.Dispose();
            }

            disposed = true;
        }
Exemplo n.º 3
0
        //dispose pattern as described on msdn for a class that uses a safe handle
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (_cancelEvent != null)
                {
                    _cancelEvent.Set();
                    Thread.Sleep(0);

                    if (_canceledEvent != null && !_canceledEvent.WaitOne(0))
                    {
                        _canceledEvent.WaitOne(2000);
                    }

                    _cancelEvent.Close();
                    _cancelEvent = null;
                }

                if (_canceledEvent != null)
                {
                    _canceledEvent.Close();
                    _canceledEvent = null;
                }
            }

            if (_toxAv != null && !_toxAv.IsInvalid && !_toxAv.IsClosed)
            {
                _toxAv.Dispose();
                _toxAv = null;
            }

            _disposed = true;
        }