Недавно я создал службу Windows, которая может помочь отследить время начала и окончания процесса, но я обнаружил, что всякий раз, когда выполняется addhandler [process] .exited, служба Windows останавливается
Вот мои коды для обработчика
For Each chrome_p As Process In NewChromeProccess
chrome_p.EnableRaisingEvents = True
AddHandler chrome_p.Exited,
Sub()
Using sw As StreamWriter = New StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\MonitoringApplication.txt", True)
ChromeEndTime.Add(chrome_p.ExitTime)
sw.WriteLine($"Process: {chrome_p.ProcessName}, Exit Time: {chrome_p.ExitTime}")
End Using
End Sub
Next
The description for Event ID 0 from source Service1 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Service cannot be started. An instance of the service is already running