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;
}
}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值