Esempio n. 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtility.Dispose(ref _serialPort);
     }
 }
Esempio n. 2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtility.Dispose(ref _udpClient);
     }
 }
Esempio n. 3
0
 /// <summary>
 ///     Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing">
 ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
 ///     unmanaged resources.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtility.Dispose(ref _streamResource);
     }
 }
Esempio n. 4
0
        private WaitHandle GetWaitHandle()
        {
            // check if needs to be created
            if (m_waitHandle == null)
            {
                // create a new manual reset event with the correct state
                bool             bWasCompleted = IsCompleted;
                ManualResetEvent mre           = new ManualResetEvent(bWasCompleted);

                if (Interlocked.CompareExchange(ref m_waitHandle, mre, null) != null)
                {
                    // we lost the race to create the event; dispose the unnecessary one
                    DisposableUtility.Dispose(ref mre);
                }
                else
                {
                    if (!bWasCompleted && IsCompleted)
                    {
                        // if the operation wasn't done when we created the event but is done now, set the event
                        m_waitHandle.Set();
                    }
                }
            }

            return(m_waitHandle);
        }
Esempio n. 5
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtility.Dispose(ref _networkStream);
     }
 }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                DisposableUtility.Dispose(ref _client);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                _masters.IfNotNull(m => m.Values.ForEach(client => DisposableUtility.Dispose(ref client)));
            }
        }
Esempio n. 8
0
        public void Dispose()
        {
            DisposableClass?d     = new DisposableClass();
            var             dCopy = d;

            Assert.IsFalse(d.IsDisposed);
            DisposableUtility.Dispose(ref d);
            Assert.IsNull(d);
            Assert.IsTrue(dCopy.IsDisposed);
        }
Esempio n. 9
0
        /// <summary>
        /// Waits for the asynchronous operation to complete, rethrowing any exception that occurred.
        /// </summary>
        public void EndInvoke()
        {
            // wait for the operation if necessary
            if (!IsCompleted)
            {
                GetWaitHandle().WaitOne();
            }

            // close the wait handle
            DisposableUtility.Dispose(ref m_waitHandle);

            // rethrow any exception that occurred during processing
            if (m_exception != null)
            {
                throw m_exception;
            }
        }
Esempio n. 10
0
 /// <summary>
 ///     Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing">
 ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
 ///     unmanaged resources.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
         DisposableUtility.Dispose(ref _transport);
 }