Wait for System.Threading.Timer Callbacks to Complete before Exiting Program

后端 未结 4 458
抹茶落季
抹茶落季 2021-01-11 15:12

I have a List. Each Timer fires at a configurable interval (default 10 minutes). All call the same callback method (with a diffe

4条回答
  •  梦谈多话
    2021-01-11 15:40

    It's probably not possible to wait for exit in console application.

    For windows forms application:

    You can create a static running callback counter variable which will be increased each time the callback is started and decreased on exit. Of course, you should use lock when doing this.

    And then you can check the corresponding event and whether wait for a counter to become 0 or just to cancel the exit.

提交回复
热议问题