MDI forms and threads

M

Mike

I have the following scenario that I'm not quite sure how to implement.





I have a form called frmMain that it's a MDI container, and a form
called frmChild, which some instances of it will be contained in
frmMain.

I also have a procedure called DoSomething that fires in the LOAD event
of frmMain, by the way, it is lunched in its own thread other than the
thread were frmMain was created.

I do this because this procedure (DoSomething) it's a beast (it uses a
lot of CPU resources).

Inside DoSomething, some stuff will happen that will require an instance
of frmChild to be generated and of course it will be contained inside
frmMain.

While DoSomething runs, several instances of frmChild might be
generated.

My problem happens when I try to instantiate a frmChild object, and
declaring its Parent property equal to frmMain, because the complier
says I'm doing this in an unsafe manner, trying to access a form from a
thread other than the one it was created on.



I need a solution for this, it might be a solution for the compiler's
exception, or another since you already now what I'm trying to
accomplish.



I really appreciate it.



Later!
 
M

Mike

Any idea guys?



_____

From: Mike [mailto:[email protected]]
Posted At: Tuesday, September 26, 2006 11:34 PM
Posted To: microsoft.public.dotnet.languages.vb
Conversation: MDI forms and threads
Subject: MDI forms and threads




I have the following scenario that I'm not quite sure how to implement.





I have a form called frmMain that it's a MDI container, and a form
called frmChild, which some instances of it will be contained in
frmMain.

I also have a procedure called DoSomething that fires in the LOAD event
of frmMain, by the way, it is lunched in its own thread other than the
thread were frmMain was created.

I do this because this procedure (DoSomething) it's a beast (it uses a
lot of CPU resources).

Inside DoSomething, some stuff will happen that will require an instance
of frmChild to be generated and of course it will be contained inside
frmMain.

While DoSomething runs, several instances of frmChild might be
generated.

My problem happens when I try to instantiate a frmChild object, and
declaring its Parent property equal to frmMain, because the complier
says I'm doing this in an unsafe manner, trying to access a form from a
thread other than the one it was created on.



I need a solution for this, it might be a solution for the compiler's
exception, or another since you already now what I'm trying to
accomplish.



I really appreciate it.



Later!
 

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