gerry99
asked on
How to avoid BeginInvoke before a handle has been created
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
This message bugs me.
To avoid cross threading exceptions in my application I use BeginInvoke to update the StatusBar of my application. The thread that updates the status bar does not know if it has been given a window handle yet, and checking for the existence of a handle tosses an exception. If you write directly to a control, before it has a handle, no problem. It is only when using method invocation that the window handle is necessary.
Does anyone have a design pattern to avoid this problem?
Thanks,
Gerry
This message bugs me.
To avoid cross threading exceptions in my application I use BeginInvoke to update the StatusBar of my application. The thread that updates the status bar does not know if it has been given a window handle yet, and checking for the existence of a handle tosses an exception. If you write directly to a control, before it has a handle, no problem. It is only when using method invocation that the window handle is necessary.
Does anyone have a design pattern to avoid this problem?
Thanks,
Gerry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Damn, wrong thread.
Just shows, test the code rather than relying on the documentation :-)