示例#1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Shuts down this object and frees any resources it is using. </summary>
        ///
        /// <returns>   True if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public virtual bool Shutdown()
        {
            using (var scope = IOCContainer?.BeginLifetimeScope())
            {
                var logger = scope?.Resolve <MSBaseLogger>();
                logger?.LogInformation(Name + " Microservice Shutting Down");
                Console.WriteLine(Name + " Microservice Shutting Down", Color.Yellow);
            }
            return(true);
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Stops this object. </summary>
        ///
        /// <returns>   True if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public virtual bool Stop()
        {
            using (var scope = IOCContainer?.BeginLifetimeScope())
            {
                var logger = scope?.Resolve <MSBaseLogger>();
                logger?.LogInformation(Name + " Microservice Stopping");
                Console.WriteLine(Name + " Microservice Stopping", Color.Yellow);
            }
            Assumes.True(_log != null, string.Intern("_log is null"));
            _log?.Info(_name + string.Intern(" Service is Stopped"));

            Assumes.True(_timer != null, string.Intern("_timer is null"));
            _timer.AutoReset = false;
            _timer.Enabled   = false;
            _timer.Stop();
            return(true);
        }