How to notify "main" thread from some other thread ?

  • Thread starter Thread starter Pawe³
  • Start date Start date
P

Pawe³

Hi everyone!
I have some problem, and have no clue how to resolve it.
I wrote some C# application which shows nice GUI and then creates
long-running worker thread. I want now to recaive some kind of notify, when
the worker thread is terminated (or aborted). I've been trying delegates and
ThreadPool.RegisterWaitForSingleObject(), but this doeas not work, becouse
invoked method works within the different thread. I've got exceptions like:

Additional information: Controls created on one thread cannot be parented to
a control on a different thread.

In MFC I would send message to the window. How to resolve this problem ?..



Thanks for any help

Paul.
 
Pawe³ said:
I have some problem, and have no clue how to resolve it.
I wrote some C# application which shows nice GUI and then creates
long-running worker thread. I want now to recaive some kind of notify, when
the worker thread is terminated (or aborted). I've been trying delegates and
ThreadPool.RegisterWaitForSingleObject(), but this doeas not work, becouse
invoked method works within the different thread. I've got exceptions like:

Additional information: Controls created on one thread cannot be parentedto
a control on a different thread.

In MFC I would send message to the window. How to resolve this
problem ?..

Use Control.Invoke.

See
http://www.pobox.com/~skeet/csharp/multithreading.html#windows.forms
for more information.
 
Thank you very much !

Paul :)

Pawe³ said:
I have some problem, and have no clue how to resolve it.
I wrote some C# application which shows nice GUI and then creates
long-running worker thread. I want now to recaive some kind of notify,
when
the worker thread is terminated (or aborted). I've been trying delegates
and
ThreadPool.RegisterWaitForSingleObject(), but this doeas not work, becouse
invoked method works within the different thread. I've got exceptions
like:

Additional information: Controls created on one thread cannot be parented
to
a control on a different thread.

In MFC I would send message to the window. How to resolve this
problem ?..

Use Control.Invoke.

See
http://www.pobox.com/~skeet/csharp/multithreading.html#windows.forms
for more information.
 
Back
Top