用户无法正常工作时,winform会挂起吗? [英] winform hang when user not working?

查看:104
本文介绍了用户无法正常工作时,winform会挂起吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows应用程序上工作...我正面临问题...实际上,如果用户直到5分钟都无法使用,我想挂起我的表格.他收到一条消息,说您已经过期了. ......请解决我的问题




关于
kuldeep vyas

i m working on window app... i m facing problem......actually i want hang my form if user is not working till 5 min .he got a message you have expired ..first u login u can activate......plz solve my problem




with regards
kuldeep vyas
developer in Real Expert cor pvt ltd.

推荐答案

您将需要计时器来测量空闲时间,并需要某种跟踪机制来跟踪用户的交互与形式.如果经过了空闲时间,则必须用MessageBox等通知用户.
在这种情况下,我将使用System.Timers.Timer类.
You''ll need timer to measure idle time and some kind of tracking mechanism to keep track of user''s interaction with form. If idle time elapses then you''ll have to inform user with MessageBox etc.
In this case I would use System.Timers.Timer class.
private void someTextBox_TextChanged(object sender, EvetArgs e)
{
    //do some work
    ResetIdleTimer();
}

private void someCheckBox_ChekChanged(object sender, EvetArgs e)
{
    //do some work
    ResetIdleTimer();
}

//.....
//etc. you got the picture
//.....

private void ResetIdleTimer()
{
   idleTimer.Stop();
   idleTimer.Start();
}


void idleTimer_Elapsed(object sender, ElapsedEventArgs e)
{
    MessageBox.Show("Whatever you want to say to user");
    //your logging off code  and closing code go here
    //this.Close();
}


引入 System.Windows.Fomrs.Timer [ ^ ].设置其时间间隔 [标记 [
现在,您必须捕获每个可能的用户操作.每次与用户互动时,首先
停止 [ ^ ]计时器,然后开始 [
Incorporate a System.Windows.Fomrs.Timer[^]. Set its Interval[^] property to five minutes. Subscribe a method to its Tick[^] event. In that method, disable your Form and show the "You''ve been logged out..." message.

Now you have to catch each and every possible user intaraction. With every user interaction, first Stop[^] the timer, then Start[^] it again. AFAIR that will cause the timer to wait for Interval again. If not, set the interval before calling Start.


这篇关于用户无法正常工作时,winform会挂起吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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