设计了一个windows service来自动scan目录,如果有文件先做一些检查工作,然后upload到ftp上
code如下,DoWork 会做具体工作,现在的问题是这个windows service会自动stop,为什么? protected override void OnStart(string[] args)
        {
            File.Delete(@"C:\OrderGen\Scripts\FTPSenderLog.txt");
            _thread = new Thread(WorkerThreadFunc); 
            _thread.Name = "PNI FtpSend Thread"; 
            _thread.IsBackground = true;
            _thread.Start();         }        protected void WorkerThreadFunc()
        {
            while (!_shutdownEvent.WaitOne(0)) 
            {
                DoWork();
            } 
        }        protected override void OnStop()
        {
           _shutdownEvent.Set();
            if (!_thread.Join(3000)) 
            {
                // give the thread 3 seconds to stop
                _thread.Abort(); 
            } 
        }