/// <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!");
                        }
                    }
                }
            }
        }
Exemple #2
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!");
                        }
                    }
                }
            }
        }