4

From Thread A I wish to call MethodA() asynchronously (such that it doesn't block Thread A) to be run on Thread B a specific thread that I have started, such that it interrupts what Thread B is doing.

Is this possible without having to actively poll for MethodA() call requests in Thread B?

EDIT: more specifically, I wish for all calls to MethodA() to be on Thread B.

EDIT 2: neither thread is a UI thread. Although I know Thread B is running, it would be nice to be able to return false if its not/not throw an exception.

4

1 に答える 1

3

スレッド B ワーカーの特定の実装を作成せずに行うことは不可能です。スレッド B ワーカーは、無限ループまたは のような別のシグナリング メカニズムのようなものである必要がありますEventWaitHandle。ループの反復ごとに、スレッド B のワーカーは、別のスレッドが入力できるデリゲートのキューをチェックする必要があります。

于 2013-01-09T16:41:53.510 に答える