Why doesn't the RequestAdditionalTime() method work on restart in Vista/7?

倖福魔咒の 提交于 2019-11-29 10:21:35

If the system isn't shutting down, your service can request additional time and your process will not get killed.

If the system is shutting down, your service has to shut down. You don't even get the normal 30 seconds that a service normally gets. Shutdown is more forceful than it used to be.

In the non-shutdown case, RequestAdditionalTime() must be called more often than every 2 minutes:

    protected override void OnStop()
    {
        Thread.Sleep(60000);
        RequestAdditionalTime(180000);
        Thread.Sleep(60000);
        RequestAdditionalTime(180000);
        Thread.Sleep(5000);
    }

Note that despite the name, the time parameter is the total shutdown time requested.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!