我如何建立一个活动? [英] How Do I Build A Event?

查看:79
本文介绍了我如何建立一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的类中添加一个事件,比如文件复制进度或加密进度.....

我知道可以通过循环使用但我不知道怎么做event!

I want add a event to my class like a file copy progress or encrypt progress .....
I know that it possible by using a loop but I do not know how do this by event!

推荐答案

添加事件很简单:一个简单的代码片段来添加一个事件 [ ^ ] - 这提供了一个VS片段,使工作更轻松,但如果您愿意,它还提供原始代码那样。
Adding an event is easy: A Simple Code Snippet to Add an Event[^] - this provides a VS snippet to make the job even easier, but it also provides the raw code if you prefer that way.


尝试使用BackgroundWorker组件。您可以花费一些时间来处理诸如复制文件之类的时间,并且您可以通过使用事件来报告此任务的进度。

您可以在这里找到的好例子:

ProgressForm:链接到BackgroundWorker的简单表单 [ ^ ]



我希望它可以帮助你:)
Try to use BackgroundWorker component. You can do some time consuming taks such as copying files, and you can report progress of this task by using events.
Good example you can find here:
ProgressForm: A simple form linked to a BackgroundWorker[^]

I hope it helps you :)


这篇关于我如何建立一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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