后台工作者线程 [英] Background Worker Thread

查看:88
本文介绍了后台工作者线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#问题有没有一种方法可以创建后台工作线程,而无需在项目中使用表单.我创建了一个.dll项目,并被要求使用后台工作线程调用类/函数.我不确定该怎么做.任何帮助将是巨大的.我肯定有一个简单的答案,就是我对这个工具不熟悉.

谢谢

C# question is there a way to way to create a background worker thread without having a form in a project. I have created a .dll project and I was instructed to call a class/function using the background worker thread. I''m not sure how to do this. Any help would be great. I"m sure there is an easy answer I''m just not familiar with this tool.

Thanks

推荐答案

是的,当然.

BackgroundWorker 不需要任何用户界面.因此,您只需从System.ComponentModel处的Code创建对象即可.


Yes, of course.

BackgroundWorker does not need any User interface. So you can just create the object of it from Code, available at System.ComponentModel.


BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerAsync();




调用RunWorkerAsync后,将在新线程中调用worker_DoWork.

:)




The worker_DoWork will be called in a new thread after you call RunWorkerAsync.

:)


非常感谢您的快速响应:-D
Thanks so much for the quick response :-D


这篇关于后台工作者线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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