MultiServiceI.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.ServiceProcess;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Timers;
  11. namespace MultiService
  12. {
  13. public partial class MultiServiceI : ServiceBase
  14. {
  15. private string serviceName = "1";
  16. private System.Timers.Timer deletePathTimer = null;
  17. public MultiServiceI()
  18. {
  19. InitializeComponent();
  20. }
  21. protected override void OnStart(string[] args)
  22. {
  23. // Log that the service is running, and show what was the last to start
  24. // just to show that the "LastService" is shared between instances of
  25. // the service.
  26. Program.Log("Started MultiService I, Last Service Started = " + (Program.LastService ?? string.Empty));
  27. Program.LastService = "MultiService I";
  28. deletePathTimer = new System.Timers.Timer();
  29. deletePathTimer.Interval = (60 * 1000) * 30; // 30분 마다 실행
  30. deletePathTimer.Elapsed += Timer_Elapsed;
  31. deletePathTimer.Start();
  32. }
  33. private void Timer_Elapsed(object sender, ElapsedEventArgs e)
  34. {
  35. try
  36. {
  37. Program.Log("Started MultiService I," + serviceName);
  38. }
  39. catch (Exception ex)
  40. {
  41. }
  42. }
  43. protected override void OnStop()
  44. {
  45. deletePathTimer.Stop();
  46. }
  47. }
  48. }