Windows Service, windows

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.