How to make GUI wait for windows service?

前端 未结 5 1318
轻奢々
轻奢々 2021-01-18 03:35

I wrote a windows service and a gui for it. Of course gui mainly depends on the service. Is there a way for gui to wait for the service? Sometimes I need to reload service c

5条回答
  •  鱼传尺愫
    2021-01-18 03:45

    ServiceController has a method WaitForStatus where you pass it an argument of type ServiceControllerStatus. You can use it like this:

    controller.WaitForStatus(ServiceControllerStatus.Running);
    

提交回复
热议问题