使用vb.net在系统空闲时关闭应用程序 [英] Closing Application while system is in idle using vb.net

查看:261
本文介绍了使用vb.net在系统空闲时关闭应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果某些应用程序在vb.net中没有使用一段时间,我想关闭该应用程序.

I would like to close some application if it was not used for certain amount of time in vb.net

推荐答案

如果它是您自己的应用程序,则希望关闭,那就还算不错:
设置一个计时器,例如间隔一秒钟.
设置超时变量,并将其值设置为所需的不活动秒数.
在计时器滴答"事件处理程序中,将超时变量减少一.如果为零,则调用Application.Exit关闭您的应用程序.
当您获得用户活动(并且必须决定是什么)时,将Timeout变量重置为其原始值.

如果这是真正的VB.NET(例如在基于Web的应用程序中),则很难,因为在客户端服务器系统中很难检测到不活动!
If it is your own application you wish to close, then it isn''t too bad:
Set up a timer, with (say) a one second interval.
Set up a timeout variable, and set it''s value to the number of seconds of inactivity you want.
In the Timer Tick event handler, reduce the timeout variable by one. If it is zero, then call Application.Exit to close your application.
When you get user activity (and you will have to decide what that is) reset the Timeout variable to it''s original value.

If this is VB.NET for real (as in a web based app) it is harder, as inactivity is difficult to detect in a client server system!


本教程将告诉您如何获取系统的空闲时间.然后,您可以将其与Diagnostics.Process类结合使用以终止或启动所需的任何应用程序
http://www.geekpedia.com/tutorial210_Retrieving-the-Operating-System-Idle-Time-Uptime-and-Last-Input-Time.html [
This tutorial will tell you how to get the system''s idle times. You can then combine this with the Diagnostics.Process class to kill or start any application you want
http://www.geekpedia.com/tutorial210_Retrieving-the-Operating-System-Idle-Time-Uptime-and-Last-Input-Time.html[^]

It''s a C# article, but should give you enough to look up the P/Invokes and convert.



这就是你想要的-
应用程序空闲 [
Hi,
Here is what you want-
Application Idle[^]


这篇关于使用vb.net在系统空闲时关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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