用参数启动新线程 [英] Starting new threads with arguments

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

问题描述




代码:


myClass x = new myClass();

x.dosomethingwith (x,y);

我如何使dosomethingwith(x,y)在一个单独的线程上运行,然后

通知主线程何时完成? br />

我可以使用回调(x,y)使用回调

委托来完成上述所有操作,但不能使用参数吗?


希望有人可以提供帮助:)


问候


Andrew

Hi,

code:

myClass x = new myClass();
x.dosomethingwith(x,y);
How do i make dosomethingwith(x,y) run on a separate thread, and then
inform the main thread when it has finished?

I can do all of the above without the arguments (x,y) using a callback
delegate, but not with arguments?

Hope someone can help :)

Regards

Andrew

推荐答案



" Andrew Bullock" <一个********************* @ ANDntlworldTHIS.com>写在

消息新闻:Ga ****************** @ newsfe3-gui.ntli.net ...

|

|

|代码:

|

| myClass x = new myClass();

| x.dosomethingwith(x,y);

|

|

|如何使dosomethingwith(x,y)在一个单独的线程上运行,然后

|完成后告知主线程?

|

|我可以在没有参数(x,y)的情况下使用回调来完成上述所有操作

|代表,但没有参数?

|

|希望有人能帮忙:)

|

|问候

|

|安德鲁


查看MSDN中的文档,它们包含大量的线程样本,或者阅读

这个:

http://www.yoda.arachsys.com/csharp/...rameters。 shtml


Willy。

"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:Ga******************@newsfe3-gui.ntli.net...
| Hi,
|
| code:
|
| myClass x = new myClass();
| x.dosomethingwith(x,y);
|
|
| How do i make dosomethingwith(x,y) run on a separate thread, and then
| inform the main thread when it has finished?
|
| I can do all of the above without the arguments (x,y) using a callback
| delegate, but not with arguments?
|
| Hope someone can help :)
|
| Regards
|
| Andrew

Check the docs in MSDN, they contain numerous threading samples, or read
this:

http://www.yoda.arachsys.com/csharp/...rameters.shtml

Willy.


Andrew Bullock< a *********** **********@ANDntlworldTHIS.com>写道:
Andrew Bullock <an*********************@ANDntlworldTHIS.com> wrote:
代码:

myClass x = new myClass();
x.dosomethingwith(x,y);

如何我是否在一个单独的线程上运行dosomethingwith(x,y),然后在完成后通知主线程?

我可以在没有参数的情况下完成上述所有操作(x ,y)使用回调
代表,但没有参数?

希望有人可以提供帮助:)
code:

myClass x = new myClass();
x.dosomethingwith(x,y);
How do i make dosomethingwith(x,y) run on a separate thread, and then
inform the main thread when it has finished?

I can do all of the above without the arguments (x,y) using a callback
delegate, but not with arguments?

Hope someone can help :)




参见 http://www.pobox.com/~skeet/csharp/ t ... rameters.shtml


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet

如果回复小组,请不要给我发邮件



See http://www.pobox.com/~skeet/csharp/t...rameters.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Willy Den oyette [MVP]写道:
Willy Denoyette [MVP] wrote:
" Andrew Bullock" <一个********************* @ ANDntlworldTHIS.com>在
消息新闻中写道:Ga ****************** @ newsfe3-gui.ntli.net ...
|
|
|代码:
|
| myClass x = new myClass();
| x.dosomethingwith(x,y);
|
|
|我如何使dosomethingwith(x,y)在一个单独的线程上运行,然后
|完成后告知主线程?
|
|我可以使用回调
|在没有参数(x,y)的情况下完成上述所有操作代表,但没有参数?
|
|希望有人可以帮忙:)
|
|问候
|
|安德鲁

检查MSDN中的文档,它们包含大量的线程示例,或者读取这个:

http://www.yoda.arachsys.com/csharp/...rameters.shtml
Willy。
"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:Ga******************@newsfe3-gui.ntli.net...
| Hi,
|
| code:
|
| myClass x = new myClass();
| x.dosomethingwith(x,y);
|
|
| How do i make dosomethingwith(x,y) run on a separate thread, and then
| inform the main thread when it has finished?
|
| I can do all of the above without the arguments (x,y) using a callback
| delegate, but not with arguments?
|
| Hope someone can help :)
|
| Regards
|
| Andrew

Check the docs in MSDN, they contain numerous threading samples, or read
this:

http://www.yoda.arachsys.com/csharp/...rameters.shtml

Willy.



您好,感谢您的回复和其他主题:)


Andrew


Hi, thanks for your response here and the other thread :)

Andrew


这篇关于用参数启动新线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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