Windows Service, windows
1 public partial class Service1: ServiceBase 2 {3 4 public Service1 () 5 {6 InitializeComponent (); 7} 8 9 protected override void OnStop () 10 {11 // service end code 12} 13 protected override void OnPause () 14 {15 // service pause code 16 base. onPause (); 17} 18 protected override void OnContinue () 19 {20 // Service Recovery Execution Code 21 base. onContinue (); 22} 23 protected override void OnShutdown () 24 {25 // The system is about to close the Execution Code 26 base. onShutdown (); 27} 28 29 30 31 protected override void OnStart (string [] args) 32 {33 System. timers. timer timer = new System. timers. timer (10000000); // interval of 10 seconds 34 timer. autoReset = true; 35 timer. enabled = false; // run 36 timer at a time. elapsed + = new ElapsedEventHandler (WriteSomething); 37 timer. start (); 38} 39 40 41 42 43 44 private void WriteSomething (object source, System. timers. elapsedEventArgs e) 45 {46 47 try48 {49 50 CreateTeam (); 51 CreatePerson (); 52 UploadAllDir (); 53} 54 catch55 {56} 57 finally58 {59 60} 61} 62 63 64 public void CreatePerson () 65 {66 67} 68 69 70 71 public void CreateTeam () 72 {73 74} 75 76 77 public void UploadAllDir () 78 {79 80} 81 82 83}View Code
Thanks to Baidu experience sharer: article