3
我正在構建一個應用程序監視服務來寫入事件日誌,以便我可以獲得計算機使用頻率的一般概念。我可以安裝該服務,當我嘗試運行它時,出現此錯誤:服務應用程序不會保持運行
「本地計算機上的應用程序監視器服務已啓動,然後停止。如果某些服務沒有任何工作要做,則會自動停止,例如性能日誌和警報服務「。
我試過了一段時間的循環,鼠標活動等...但它不斷結束。關於我能做什麼的想法?
public ApplicationMonitor()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("Activity Usage"))
{
System.Diagnostics.EventLog.CreateEventSource("Activity Usage", "Computer Log");
}
eventLog1.Source = "Activity Usage";
eventLog1.Log = "Computer Log";
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
eventLog1.WriteEntry("In onStop.");
}
protected override void OnContinue()
{
eventLog1.WriteEntry("In OnContinue.");
}