all groups > dotnet compact framework > june 2003 >
You're in the

dotnet compact framework

group:

Raise event from library worker thread.


Raise event from library worker thread. franson NO[at]SPAM hotmail.com
6/30/2003 10:47:33 AM
dotnet compact framework:
Hi!

I am writing a library in managed C++ for the .NET framework. I have
problems fireing events from a worker thread. The managed event must
be raised from the main thread, but I cannot find any way to pass
control from the worker thread to the main thread.

In the COM programming model the problem was solved by creating an
invisible window which the worker thread passed win32 messages to.
With what is that paradigm replaced in .NET?

I have found some solutions that involves the Control.Invoke method.
This approach works if you got access to the clients Form handle, but
since I am writing a library (and not a control) I don't now how to
get that. Instead I get this error message if a I let my class inherit
from Control and then call Invoke()

"An unhandled exception of type 'System.InvalidOperationException'
occurred in system.windows.forms.dll

Additional information: Cannot call Invoke or InvokeAsync on a control
until the window handle has been created."

Do anyone have the solution of how to raise events from a .NET
library's worker thread? I would be more than pleased if I anyone gave
me some key information!

Regards,
Re: Raise event from library worker thread. Alex Feinman [MVP]
6/30/2003 11:18:39 AM
You can use MessageWindow class in a same way you used hidden window in COM

[quoted text, click to view]
Re: Raise event from library worker thread. franson NO[at]SPAM hotmail.com
7/7/2003 2:53:04 PM
Thanks for your answer, but as I understand it MessageWindow is only
implemented in the Compact Framework and not the desktop framework. At
least the docs say so, and the postings from Microsoft staf in those
groups say so.

Any solution for .NET Desktop Framework?

Regards,
John

[quoted text, click to view]
AddThis Social Bookmark Button