Guest User

Untitled

a guest
Jan 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Public partial class MiServicio : ServiceBase
  2. {
  3.  
  4. Timer tmrServicio = null;
  5.  
  6. public MiServicio ()
  7. {
  8. InitializeComponent();
  9. tmrServicio = new Timer (1000);
  10. tmrServicio.Elapsed += new ElapsedEventHandler(tmrServicio_Elapsed);
  11. }
  12.  
  13. void tmrServicio_Elapsed(object sender, ElapsedEnvetArgs e)
  14. {
  15. VerificarAppIniciado();
  16. }
  17.  
  18. protected override void OnStart(string[] args)
  19. {
  20. tmrServicio.Start();
  21. }
  22.  
  23. protected override void OnStop()
  24. {
  25. tmrServicio.Stop();
  26. }
  27.  
  28. void VerificarAppIniciar()
  29. {
  30. Process[] apps = Process.GetProcessesByName("sistemaventas");
  31. if (apps.Length == 0)
  32. {
  33. try
  34. {
  35. Process.Start(@"C:Archivos de programaMiAppsistemaventas.exe");
  36. }
  37. catch
  38. {
  39. }
  40. }
  41. }
  42. }
Add Comment
Please, Sign In to add comment