Window Handle error caused when BeginInvoke() method is called

T

teixeira1985

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
Edit/Delete Message
 
T

teixeira1985

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top