Exemplo n.º 1
0
        /// <inheritdoc />
        public ReattachInformation Release()
        {
            CheckDisposed();
            //we still don't want to dispose the dmb yet, even though we're keeping it alive
            var tmpProvider = reattachInformation.Dmb;

            reattachInformation.Dmb = null;
            released = true;
            Dispose();
            Dmb.KeepAlive();
            reattachInformation.Dmb = tmpProvider;
            return(reattachInformation);
        }
        /// <summary>
        /// Implements the <see cref="IDisposable"/> pattern
        /// </summary>
        /// <param name="disposing">If this function was NOT called by the finalizer</param>
        void Dispose(bool disposing)
        {
            lock (synchronizationLock)
            {
                if (disposed)
                {
                    return;
                }
                if (disposing)
                {
                    if (!released)
                    {
                        process.Terminate();
                        byondLock.Dispose();
                    }

                    process.Dispose();
                    bridgeRegistration.Dispose();
                    Dmb?.Dispose();                     // will be null when released
                    chatTrackingContext.Dispose();
                    reattachTopicCts.Dispose();
                    disposed = true;
                }
                else
                {
                    if (logger != null)
                    {
                        logger.LogError("Being disposed via finalizer!");
                    }
                    if (!released)
                    {
                        if (process != null)
                        {
                            process.Terminate();
                        }
                        else if (logger != null)
                        {
                            logger.LogCritical("Unable to terminate active DreamDaemon session due to finalizer ordering!");
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Implements the <see cref="IDisposable"/> pattern
        /// </summary>
        /// <param name="disposing">If this function was NOT called by the finalizer</param>
        void Dispose(bool disposing)
        {
            lock (this)
            {
                if (disposed)
                {
                    return;
                }
                if (disposing)
                {
                    if (!released)
                    {
                        process.Terminate();
                        byondLock.Dispose();
                    }

                    process.Dispose();
                    interopContext.Dispose();
                    Dmb?.Dispose();                     // will be null when released
                    chatJsonTrackingContext.Dispose();
                    disposed = true;
                }
                else
                {
                    if (logger != null)
                    {
                        logger.LogError("Being disposed via finalizer!");
                    }
                    if (!released)
                    {
                        if (process != null)
                        {
                            process.Terminate();
                        }
                        else if (logger != null)
                        {
                            logger.LogCritical("Unable to terminate active DreamDaemon session due to finalizer ordering!");
                        }
                    }
                }
            }
        }