Question Opening form using a threadpool

ksmshsjs

New member
Joined
Sep 15, 2009
Messages
4
Programming Experience
1-3
Hello,

I am facing this problem:
I want to open a VB.net form using a ThreadPool with a maximum of 10 threads. I need to do this because, the form should open based on a live event and i need atmost 10 forms on the desktop at a time. If i open the form on every live event without using a ThreadPool, the desktop will be floaded with many forms.
I am using QueueUserWorkItem method of threadpool to queue a method which opens the form. In this queued method, there is form1.show() statement called. But after displaying the form, this method finishes execution and again we have 10 threads available in the system.
I somehow want to either keep this method running so that 1 thread is occupied or i want to keep the thread alive till the form1 is closed by the user.
I want the 11th form to appear on the desktop, only when any of the existing forms out of the 10 (already on desktop) is closed.

Please help me out as i am stuck at this point
Thanks & Regards,
ksmshsjs
 
You're going about this the wrong way. Don't use the ThreadPool at all. Just keep track of the number of forms you have open. It's a simple number. Just put your pending forms in a queue and when one closes open the next.
 
Back
Top