private void fileCreated(object sender, System.IO.FileSystemEventArgs e) { MyServiceLogger.Log(e.Name + " Dropped At :" + DateTime.Now.TimeOfDay.ToString()); childThread = new Thread(() => MainLogic.testingAndMoving(e.FullPath)); if (!MainLogic.isFileLocked(new FileInfo(e.FullPath))) { childThread.Start(); } else { childThread.Suspend(); System.Timers.Timer ticker = new System.Timers.Timer(900000); ticker.Elapsed += delegate { restartThread(childThread, ticker); }; ticker.Enabled = true; ticker.Start(); } }
protected override void OnStop() { fileSystemWatcher1.EnableRaisingEvents = false; MyServiceLogger.Log("Stopped Service At: " + DateTime.Now.TimeOfDay.ToString()); }
protected override void OnStart(string[] args) { fileSystemWatcher1.EnableRaisingEvents = true; MyServiceLogger.Log("Started Moving Service At: " + DateTime.Now.TimeOfDay.ToString()); }