Reputation: 14379
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.
Upvotes: 4
Views: 120
Reputation: 900
It is impossible to do without creating a specific implementation of Thread B worker.
Thread B worker should be something like infinite-loop or another signaling mechanism like EventWaitHandle
. On each iteration of loop Thread B worker should check some queue of delegates which can be populated by another thread.
Upvotes: 3