确定关闭的关闭我的应用程序 [英] Ascertaining a shutdown is closing my application

查看:153
本文介绍了确定关闭的关闭我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在.NET中,以确定是否我的应用程序被关闭,由于到Windows被赋予了shutdown命令,以便(而不是任何旧的应用程序关闭)要么写了一些临时缓存文件,甚至阻止关机时间足够长以提示用户输入?

Is it possible in .NET to ascertain whether my application is closing due to Windows being given a shutdown command (as opposed to any old application closing) in order to either write out some temporary cache files or even block the shutdown long enough to prompt for user input?

虽然我目前的范围涉及一个WinForm的应用程序和窗口服务,我很感兴趣的,如果可能的一种通用的方式理解这个

Whilst my current scope involves a Winform app and a windows service, I am interested in understanding this in a generic way if possible

推荐答案

<一个href="http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.sessionending.aspx">SystemEvents.SessionEnding看起来像一个很好的起点为您服务。何时注销/关机发生涉及的事件序列论述。

SystemEvents.SessionEnding looks like a good starting point for you. That article talks about the event sequence involved when a logout/shutdown is occurring.

这篇关于确定关闭的关闭我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆