Esempio n. 1
0
        /// <summary>
        /// Releases any important resources assocated with the instance.
        /// </summary>
        /// <param name="disposing"><c>true</c> if the instance is being disposed as opposed to being finalized.</param>
        protected void Dispose(bool disposing)
        {
            lock (syncLock)
            {
                if (outbox != null)
                {
                    outbox.Close();
                    outbox = null;
                }

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

                if (disposing)
                {
                    GC.SuppressFinalize(this);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Releases any important resources assocated with the instance.
        /// </summary>
        /// <param name="disposing"><c>true</c> if the instance is being disposed as opposed to being finalized.</param>
        protected void Dispose(bool disposing)
        {
            lock (syncLock)
            {
                if (outbox != null)
                {
                    outbox.Close();
                    outbox = null;
                }

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

                if (timeoutTask != null)
                {
                    timeoutCts.Cancel();

                    try
                    {
                        timeoutTask.Wait(TimeSpan.FromSeconds(1));
                    }
                    catch (TimeoutException)
                    {
                        // Ignore these.
                    }

                    timeoutTask = null;
                }

                if (disposing)
                {
                    GC.SuppressFinalize(this);
                }
            }
        }