C# 如何在Windows对话框中更新服务状态
如何更新Windows服务对话框中的C# 如何在Windows对话框中更新服务状态,c#,windows,windows-services,C#,Windows,Windows Services,如何更新Windows服务对话框中的状态列 当服务进入(托管)故障状态时…我想更新对话框 我不想回答我自己的问题,但是没有人回答这个问题 不幸的是,事实证明,您无法直接更新状态字段,因为它是只读的。但是,您可以暂停服务,如下所示: var serviceController = new ServiceController(ServiceName); serviceController.Pause(); // Pauses the service serviceController.
状态
列
- 当服务进入(托管)故障状态时…我想更新对话框
我不想回答我自己的问题,但是没有人回答这个问题 不幸的是,事实证明,您无法直接更新
状态
字段,因为它是只读的。但是,您可以暂停服务,如下所示:
var serviceController = new ServiceController(ServiceName);
serviceController.Pause(); // Pauses the service
serviceController.Refresh(); // Refreshes the Dialog UI with the new Status
这是不幸的,因为没有“真正”的方法来显示服务的故障状态