Beispiel #1
0
    ///////////////////////////////////////////////////////////////////
    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");
    }