MultiServiceII.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. partial class MultiServiceII : ServiceBase
  14. {
  15. private string serviceName = "2";
  16. private System.Timers.Timer deletePathTimer = null;
  17. public MultiServiceII()
  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 II, Last Service Started = " + (Program.LastService ?? string.Empty));
  27. Program.LastService = "MultiService II";
  28. }
  29. private void Timer_Elapsed(object sender, ElapsedEventArgs e)
  30. {
  31. try
  32. {
  33. Program.Log("Started MultiService II," + serviceName);
  34. }
  35. catch (Exception ex)
  36. {
  37. }
  38. }
  39. protected override void OnStop()
  40. {
  41. deletePathTimer.Stop();
  42. }
  43. }
  44. }