Exemplo n.º 1
0
        /// <summary>
        /// Shutdown all running Trinity servers. This only works in the Client mode.
        /// </summary>
        public unsafe void ShutDown()
        {
            //TODO should be IDisposable, not ShutDown
            //TODO move this to base implementation;
            if (TrinityConfig.CurrentRunningMode == RunningMode.Client)
            {
                try
                {
                    // Trigger the initialization if not initialized yet
                    var proxies = ProxyList;

                    BackgroundThread.ClearAllTasks(); // To disable heartbeat
                    Parallel.For(0, PartitionCount, i =>
                    {
                        ShutDown(i);
                    }
                                 );
                    Parallel.ForEach <RemoteStorage>(proxies, proxy =>
                    {
                        ShutDownProxy(proxy);
                        proxy.Dispose();
                    });
                    Dispose();
                    Thread.MemoryBarrier();
                }
                catch (Exception ex)
                {
                    Log.WriteLine(LogLevel.Error, "Errors occurred during shutdown the Trinity servers.");
                    Log.WriteLine(LogLevel.Error, ex.ToString());
                }
            }
        }