自动功能 [英] Auto Function

查看:84
本文介绍了自动功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有
我想使自动功能意味着功能运行时没有任何事件,例如form_load或button_clilck或......

并且此功能可以在不影响应用平均值的情况下运行(用户可以在自动功能运行时更新数据库并在程序上进行操作...

任何想法,如果可能的话!!!! thx for read

hey all
i wanna to make auto function means function run without any event like form_load or button_clilck or ......

and this function run without any affect on the applictaion mean ( user can update database and work on program when the auto funtion run...

any idea if this possible!!!!!
thx for read

推荐答案

好吧,这并不难.您想要做的是在表单中添加一个Timer并将其Interval设置为1000 ms(等于1 sec).

(有关计时器的文章,请参见:初学者使用计时器的指南 [ ^ ])

然后,当它打勾时,您将启动BackgroundWorker并告诉它执行您想要的操作.我建议在Google或此处的文章中查找BackgroundWorker.一个良好的开端可能是:

BackgroundWorker线程和支持取消功能 [ .NET入门线程指南(第5部分,n) [
Well, that''s not that hard to do. What you want to do is add a Timer to your form and set it''s Interval to 1000 ms (equals 1 sec).

(An article on Timer''s can be found here: Pre-beginner''s guide to using a timer[^])

Then, when it ticks, you start up a BackgroundWorker and tell it to do what you want. I suggest looking up BackgroundWorker on google, or in the articles here. A good start might be:

BackgroundWorker Threads and Supporting Cancel[^]

or here:
Beginners Guide To Threading In .NET Part 5 of n[^]

The BackgroundWorker is a bit much to get into in a quick answer, but there is a ton of information available on the web.


这篇关于自动功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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