C# Console Application - Keep it running

前端 未结 11 1716
萌比男神i
萌比男神i 2020-12-16 01:02

I am about to develop a console application that will be required to continually run and carry out work at specific times.

My question is what is are best methods or

11条回答
  •  [愿得一人]
    2020-12-16 01:38

    While you should really be using a service for this, if you need/want to do this anyway, you can use a ManualResetEvent to do this:

    private ManualResetEvent Wait = new ManualResetEvent(false);
    

    When you're finished 'starting' and want to just wait, you'd then do:

    Wait.WaitOne();
    

    When you want to stop and let it exit, you can then do:

    Wait.Set();
    

提交回复
热议问题