protected override void OnStart(string[] args) { bool verbose = false; // look in this exe's folder for the config, not the c:\ root folder. string this_exe = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; pop3 = new POP3Main(System.IO.Path.GetDirectoryName(this_exe) + "\\btnet_service.exe.config", verbose); OnContinue(); }
/////////////////////////////////////////////////////////////////////// public static void Main(string[] args) { // check the command line if (args.Length != 1) { Console.WriteLine( "usage\nbtnet_console.exe [path to btnet_service.exe.config file]"); Console.WriteLine( "example\nbtnet_console.exe btnet_service.exe.config"); return; } // Get the configuration settings bool verbose = true; POP3Main pop3 = new POP3Main(args[0], verbose); pop3.start(); Console.WriteLine("Hit enter to quit."); Console.Read(); pop3.stop(); }
/////////////////////////////////////////////////////////////////// public void watchdog_thread_proc() { POP3Main.write_line("entering watchdog thread"); while (true) { System.Threading.Thread.Sleep(2000); if (state == service_state.STOPPED) { break; } else { TimeSpan timespan = DateTime.Now.Subtract(heartbeat_datetime); if (timespan.TotalSeconds > RespawnFetchingThreadAfterNSecondsOfInactivity) { POP3Main.write_line("WARNING - watchdog thread is killing fetching thread"); fetching_thread.Abort(); fetching_thread = new System.Threading.Thread(new System.Threading.ThreadStart(fetching_thread_proc)); POP3Main.write_line("WARNING - watchdog thread is starting new fetching thread"); fetching_thread.Start(); } } } POP3Main.write_line("exiting watchdog thread"); }