コード例 #1
0
        /// <summary>
        /// Run method helper.
        /// </summary>
        /// <remarks>
        /// Makes this Orleans silo begin executing and become active.
        /// Note: This method call will only return control back to the caller when the silo is shutdown or
        /// an external request for cancellation has been issued.
        /// </remarks>
        /// <param name="cancellationToken">Optional cancellation token.</param>
        private void RunImpl(CancellationToken?cancellationToken = null)
        {
            logger.Info(ErrorCode.Runtime_Error_100289, "OrleansAzureHost entry point called");

            // Hook up to receive notification of Azure role stopping events
            serviceRuntimeWrapper.SubscribeForStoppingNotification(this, HandleAzureRoleStopping);

            if (host.IsStarted)
            {
                if (cancellationToken.HasValue)
                {
                    host.WaitForSiloShutdown(cancellationToken.Value);
                }
                else
                {
                    host.WaitForSiloShutdown();
                }
            }
            else
            {
                throw new Exception("Silo failed to start correctly - aborting");
            }
        }