SIr,当表单可见性隐藏时,如何在后台使用计时器? [英] SIr, how can I use timer at back ground when form visibility is hide ?

查看:93
本文介绍了SIr,当表单可见性隐藏时,如何在后台使用计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,



我正在申请有一个警报选项。我希望如果申请被关闭,当闹钟时间到来时,表格必须显示警报。我怎么能这样做请建议我先生。当应用程序隐藏它在后台工作时我被带了一个通知控件我希望那个计时器应该在后台工作,以便在闹钟时间到来时显示表单。

Sir,

I am making an application there is an alarm option.I want that if application is closed and when the alarm time will come then form have to show the alarm. how can I do that please suggest me sir. I am taken a notify control when application goes hide its working in background I want that timer should work on background to show the form when alarm time come.

推荐答案

你'我可能会在您的表单上放置一个Timer控件。如果表单被隐藏(即关闭),我认为这不会起作用。



如果你动态创建一个计时器,它应该工作...这里是一个我的意思非常简单的例子......我创建了一个带有单个按钮的表单,然后添加了这个代码

You've probably put a Timer control onto your form. I don't think that will work if the form is hidden (i.e. closed).

If you create a timer dynamically then it should work ... here is a very simple example of what I mean ... I created a form with a single button then added this code
Private Sub Command_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command.Click
    Dim t As Timer = New Timer()
    AddHandler t.Tick, AddressOf Timer1_Tick
    t.Interval = 10000
    Me.Hide()
    t.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Me.Show()
End Sub



当我运行程序并单击按钮时,表单被隐藏但程序仍在运行。 10秒后表格重新出现。



我不熟悉任何通知控件,但你应该能够动态地创建其中一个


When I run the program and click the button, the form is hidden but the program is still running. After 10 seconds the form reappears.

I'm not familiar with any notify control, but you should be able to create one of those dynamically too


这篇关于SIr,当表单可见性隐藏时,如何在后台使用计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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