如何为Windowsforms(C#)测验应用程序设置超时 [英] How to Set a TimeOut for a windowsforms(C#) quiz Application

查看:92
本文介绍了如何为Windowsforms(C#)测验应用程序设置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户登录进行测试
二十分钟后,它会自动退出

我该如何在Windows Froms应用程序中使用C#

user getting login for a Test
after twenty minutes it get sign out automatically

how can i achieve this in Windows Froms Application using C#

推荐答案

实现此功能,哥们,为此可以使用计时器.
Hey buddy, use can use timer for this.
private void Form1_Load(object sender, EventArgs e)
    {
        Timer MyTimer = new Timer();
        MyTimer.Interval = (20 * 60 * 1000); // 20 mins
        MyTimer.Tick += new EventHandler(MyTimer_Tick);
        MyTimer.Start();
    }

    private void MyTimer_Tick(object sender, EventArgs e)
    {
        MessageBox.Show("The form will now be closed.", "Time Elapsed");
        this.Close();
    }


这篇关于如何为Windowsforms(C#)测验应用程序设置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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