コード例 #1
0
ファイル: Program.cs プロジェクト: belegoth/LogMonitor
        public static void Main()
        {
            try
            {
                if (Environment.UserInteractive)
                {
                    using (var starter = new ConfigurationAppStarter())
                    {
                        using (starter.Start())
                        {
                            Console.ReadLine();
                        }
                    }
                }
                else
                {
                    ServiceBase.Run(new WindowsService());
                }
            }
            catch (SystemException exception)
            {
                var color = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine(exception.Message);
                Console.ForegroundColor = color;

                Console.WriteLine();
            }
        }
コード例 #2
0
        public static void Main()
        {
            try
            {
                if (Environment.UserInteractive)
                {
                    using (var starter = new ConfigurationAppStarter())
                    {
                        using (starter.Start())
                        {
                            Console.ReadLine();
                        }
                    }
                }
                else
                {
                    ServiceBase.Run(new WindowsService());
                }
            }
            catch (SystemException exception)
            {
                var color = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine(exception.Message);
                Console.ForegroundColor = color;

                Console.WriteLine();
            }
        }
コード例 #3
0
        protected override void OnStop()
        {
            if (this.kernel != null)
            {
                this.kernel.Dispose();
                this.kernel = null;
            }

            if (this.starter != null)
            {
                this.starter.Dispose();
                this.starter = null;
            }
        }
コード例 #4
0
ファイル: WindowsService.cs プロジェクト: belegoth/LogMonitor
        protected override void OnStop()
        {
            if (this.kernel != null)
            {
                this.kernel.Dispose();
                this.kernel = null;
            }

            if (this.starter != null)
            {
                this.starter.Dispose();
                this.starter = null;
            }
        }
コード例 #5
0
        /// <summary>
        /// Called when [start].
        /// </summary>
        /// <param name="args">The args.</param>
        protected override void OnStart(string[] args)
        {
#if DEBUGGER
            Debugger.Launch();
#endif

            try
            {
                this.starter = new ConfigurationAppStarter();
                this.kernel  = this.starter.Start();
            }
            catch (Exception exception)
            {
                this.applicationEventLog.WriteEntry(exception.ToString(), EventLogEntryType.Error);

                // Don't start, if initialization wasn't successfull.
                throw;
            }
        }
コード例 #6
0
ファイル: WindowsService.cs プロジェクト: belegoth/LogMonitor
        /// <summary>
        /// Called when [start].
        /// </summary>
        /// <param name="args">The args.</param>
        protected override void OnStart(string[] args)
        {
            #if DEBUGGER
            Debugger.Launch();
            #endif

            try
            {
                this.starter = new ConfigurationAppStarter();
                this.kernel = this.starter.Start();
            }
            catch (Exception exception)
            {
                this.applicationEventLog.WriteEntry(exception.ToString(), EventLogEntryType.Error);

                // Don't start, if initialization wasn't successfull.
                throw;
            }
        }