c#中在规定时间弹出窗体

我现在做了一个幼儿教育软件~我想在规定时间提醒他关闭程序 该休息休息 了!如果他还不管3分钟内强制关闭~?请问这个该怎么弄谢谢你们?

问题补充:

我希望能给出来完整的代码 我是初学 ,,是winform程序~~
在 一个 Form 里拖 两个控件 Lable, Timer,  修改Timer属性.
Enable=true,
Interval=1000.
Id 不改保持默认。
在窗体类写一下代码:
const int closeTime = 5//关闭程序时间,秒
const int workTime = 10;
//弹出窗口所需时间,秒
int curWorkTime = 0; /
/当前时间,秒
bool needExit = false;
// 是否是关闭程序,若不是则表示弹出窗口。
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
curWorkTime++;
if (needExit)
{
label1.Text = string.Concat("剩余 ",closeTime - curWorkTime, " 秒,关闭程序。");
if (curWorkTime == closeTime)
//关闭程序
{
Application.Exit();
}
}
else
{
label1.Text = string.Concat("剩余 ", workTime - curWorkTime, " 秒,弹出窗口。");
if (curWorkTime == workTime)
//弹出窗口。
{
curWorkTime = 0;
needExit = true;
MessageBox.Show("您该休息了。");
needExit = false;
curWorkTime = 0;
}
}
}

 

posted @ 2012-12-14 21:18  麦田HH  阅读(588)  评论(0编辑  收藏  举报