如何在理想的特定时间关闭表格? [英] how to close a form when for specific time when it is ideal?

查看:79
本文介绍了如何在理想的特定时间关闭表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当c#中没有人在C#窗体中以那种形式工作时?

非常紧急,请回答

in c# when no one is working in that form in C# window forms?
Very urgent, please Answer

推荐答案

这里:用户空闲检测 [ ^ ]使用 Windows的示例imlpementation API 函数 GetLastInputInfo 。我不知道 Framework 是否提供了相同的功能。
Here: "User Idle Detection"[^] a sample imlpementation using the Windows API function GetLastInputInfo. I don't know if the Framework provides an equivalent functionality.


你可以通过 GetLastInputInfo找到空闲时间功能

然后你可以写自己的逻辑来关闭表格或你想要的东西。



这是一篇很好的文章完整的解决方案

让用户获得空闲时间C# [ ^ ]



希望,它有帮助:)
You can find the idle time through GetLastInputInfo function
and then you can write you own logic to close the form or what you want.

Here is good article with the complete solution
Getting the user idle time with C#[^]

Hope, it helps :)


关闭表单的唯一理想时间是用户通过鼠标点击或键盘明确关闭它的时间。



如果您认为您知道更准确的时间并且没有其他任何事情可做,您可以使用:

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.close%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.windows.forms.timer%28v=vs.110%29.aspx [ ^ ](这是一个非常罕见的情况,当一个人可以使用这个计时器类型,几乎没有任何好处。



但更好不做恶



-SA
The only ideal time for closing a form is the time when a user explicitly closes it by a mouse click or a keyboard.

If you think you know exact time better and has nothing else to do, you can use:
https://msdn.microsoft.com/en-us/library/system.windows.forms.form.close%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.timer%28v=vs.110%29.aspx[^] (this is one of the very rare cases when one can use this timer type, which is good almost for nothing).

But better don't do evil.

—SA


这篇关于如何在理想的特定时间关闭表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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