Torna al Thread
Protected Overrides Sub OnStart(ByVal args() As String)
Me.Timer1.Enabled = True
FileOpen(1, My.Application.Info.DirectoryPath.ToString() + "\logControllo.txt", OpenMode.Append)
Print(1, Environment.NewLine + "------------ Servizio avviato - " + Now.ToString + "-------------------" + Environment.NewLine)
FileClose()
End Sub
Protected Overrides Sub OnStop()
FileOpen(1, My.Application.Info.DirectoryPath.ToString() + "\logControllo.txt", OpenMode.Append)
Print(1, Environment.NewLine + "------------ Servizio stoppato - " + Now.ToString + "-------------------" + Environment.NewLine)
FileClose()
Me.Timer1.Enabled = False
End Sub
Private Sub AvviaProgramma()
Try
processo = Process.GetProcessesByName("nomeProcesso")
If UBound(processo) < 0 Then
Shell("C:\Programmi\mio percorso\prog.exe")
End If
Catch ex As Exception
FileOpen(1, My.Application.Info.DirectoryPath.ToString() + "\logControllo.txt", OpenMode.Append)
Print(1, "-------------------------" + Environment.NewLine + Now.ToString + Environment.NewLine + ex.ToString + Environment.NewLine)
FileClose()
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Me.Timer1.Enabled = False
AvviaProgramma()
Threading.Thread.Sleep(10000)
Me.Timer1.Enabled = True
End Sub