在BackGround Thread中使用参数并且不使用参数 [英] DoWork with Parameters and without parameters in BackGround Thread

查看:48
本文介绍了在BackGround Thread中使用参数并且不使用参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用带有参数的DoWork和没有参数的优点和缺点是什么?

What are the advantages and disadvantages of using DoWork with paramters and without parameters??

推荐答案

那么,主要的优点是你可以将参数信息传递给thread:如果不这样,则线程必须使用类级信息 - 这对于简单的情况很好 - 但是如果你想要两个或更多后台任务处理不同的数据,那么传递参数是显而易见的方法。与调用带/不带参数的方法完全相同。
Well, the main advantage is that you can pass parameter information into the thread: if you don't then the thread has to work with class level info - which is fine for simple cases - but if you want two or more background tasks working on different data, then passing parameters is the obvious way to do it. Exactly the same as calling a method with / without parameters in fact.


这篇关于在BackGround Thread中使用参数并且不使用参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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