示例#1
0
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

        /// <summary>
        /// Called when the service stops. This methods stops the silo. In most scenarios, you shouldn't override this
        /// method.
        /// </summary>
        protected override void OnStop()
        {
            if (Arguments.ServiceDrainTime.HasValue)
            {
                Kernel.Get <ServiceDrainController>().StartDrain();
                Thread.Sleep(Arguments.ServiceDrainTime.Value);
            }

            SiloHost.Stop(); // This calls BeforeOrleansShutdown()
            Dispose();
        }
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

        /// <summary>
        /// Called when the service stops. This methods stops the silo. In most scenarios, you shouldn't override this
        /// method.
        /// </summary>
        protected override void OnStop()
        {
            if (Arguments.ServiceDrainTimeSec.HasValue)
            {
                Kernel.Get <ServiceDrainController>().StartDrain();
                Thread.Sleep(Arguments.ServiceDrainTimeSec.Value * 1000);
            }

            Kernel.Get <SystemInitializer>().Dispose();
            Kernel.Get <IWorkloadMetrics>().Dispose();
            SiloHost.Stop(); // This calls BeforeOrleansShutdown()
            Dispose();
        }
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

        /// <summary>
        /// Called when the service stops. This methods stops the silo. In most scenarios, you shouldn't override this
        /// method.
        /// </summary>
        protected override void OnStop()
        {
            if (Arguments.ServiceDrainTimeSec.HasValue)
            {
                Kernel.Get <ServiceDrainController>().StartDrain();
                Thread.Sleep(Arguments.ServiceDrainTimeSec.Value * 1000);
            }

            Kernel.Get <SystemInitializer>().Dispose();
            Kernel.Get <IWorkloadMetrics>().Dispose();
            SiloHost.Stop(); // This calls BeforeOrleansShutdown()

            try
            {
                Kernel.Get <ILog>().Info(x => x("Silo stopped gracefully, trying to dispose dependencies."));
            }
            catch
            {
                Console.WriteLine("Silo stopped gracefully, trying to dispose dependencies.");
            }

            Dispose();
        }
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

        /// <summary>
        /// Called when the service stops. This methods stops the silo. In most scenarios, you shouldn't override this
        /// method.
        /// </summary>
        protected override void OnStop()
        {
            SiloHost.Stop(); // This calls BeforeOrleansShutdown()
            Dispose();
        }