Window Handle error caused when BeginInvoke() method is called

teixeira

Regular
Joined
Apr 5, 2005
Messages
94
Location
LEIRIA-PORTUGAL
Hi,

I developed an MDI Environment with several MDIchilds and i would like to prevent the same MDIClient open twice. User clicks once and opens 1 mdi client window, user clicks again and if form exists calls BringToFront() method else if not exists, recreate 1 new mdi client wnd again.
Until here all rocks, but in the second time e recreate (because doesn't exists anymore) a new mdi client window, an error ocurres, because i have a method that uses BeginInvoke((MethodInvoker) delegate{stuff to change})); inside.
The error is about the window handle...

How can i prvent this to error, but saving my need of show a single form?

Thanks in advance
 
I got this answer my self testing more.
So the way i found to solve this issue, was EXPLICITLY unregister the event handler at form closed method.
I worked, and it seems to me that the cause of all this, was because i use a paralel thread with a pooling of 200ms and at the time i wanted to create the new window maybe the handle wasn't yet created when thread wanted access it.

Thanks,
Tiago Teixeira
 
Back
Top