Pass object to create new thread with

vinnie881

Well-known member
Joined
Sep 3, 2006
Messages
152
Programming Experience
3-5
I want to open all my sub forms in a new thread. I litterally have hundreds, so I was hoping to pass the object type (frmmyform1) then it just creates a new thread of that object using application.run.

Is it possible to pass the object type and have the thread dynamically create the new object from that so I don't need a Seperate sub for each one of my hundred forms.

The forms must open in Seperate threads so I can't just pass the created new object.
 
There's no reason for you to create the forms on different threads. All the forms should be created on the same UI thread and the processing is what should be done on a secondary thread. If you tried that and it didn't work then you did it wrong. You are flat-out trying to solve the wrong problem.

That said, if you're determined to do this the wrong way then that's your prerogative. To answer your question as asked, there are a number of ways you could do it.

1. Pass a String and use a Select Case to decide which type of form to create.
2. Pass a Type object that represents the type of form to create and use Reflection to create it.
3. Pass an object with a field/property of the type of for to create a method to create it and call the method on the secondary thread.
 
All processing IS done on a secondary thread. The issue is the main ui form visually changes where current call details are displayed and call status on the main mdi ui.

So processing is done on a Seperate thread, BUT when any form opened on the main ui has a dialog showing it locks the thread doing the processing from updating the main ui as the dialog prevents function on all parents... So what is the proper way to handle that is the question, do I abandon updating the main ui with the call details forms and hangup form that all are launched from the main ui via the 2nd thread invoking it?

I hope I am explaining properly, my ideal solution is to have the main ui not effected by dialogs and the ONLY way I can think of to do so is opening the main sub forms in their own thread.
 
All processing IS done on a secondary thread. The issue is the main ui form visually changes where current call details are displayed and call status on the main mdi ui.

So processing is done on a Seperate thread, BUT when any form opened on the main ui has a dialog showing it locks the thread doing the processing from updating the main ui as the dialog prevents function on all parents... So what is the proper way to handle that is the question, do I abandon updating the main ui with the call details forms and hangup form that all are launched from the main ui via the 2nd thread invoking it?

I hope I am explaining properly, my ideal solution is to have the main ui not effected by dialogs and the ONLY way I can think of to do so is opening the main sub forms in their own thread.

YES!!! I found out in my arrangemnet GRANDFATHER(MAIN UI MDI)->PARENT->CHILD, as long as I open the PARENT with .show() instead of show dialog, then the GRANDFATHER although I can not click on it, does properly update programically!! This would've been a nightmare if it did not, so thanks. The coding changes are easy as I simply make sure every PARENT is opened using .show instead of .showdialog and all seems to work!
 
Back
Top