By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,060 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,060 IT Pros & Developers. It's quick & easy.

How to tell what other forms are opened.

P: n/a
I have an application with a menu system which creates a new thread when a
menu item is selected - some of these other threads may open a form for user
interaction.

Before the menu system is closed, I want to check that no other forms are
open - on any thread. Is there a way of checking for this easily? At
the moment, I'm not keeping track of new threads that I create ie I create
the new thread using code similar to as follows:

private sub RunMenu
dim obj as new myclass
dim t as new threading.thread(addressof obj.subroutinename)
t.start
end sub

How can I do this?

Thanks in advance
Simon

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
A very simple example:

Dim frm as Form1

If Not (frm Is Nothing) Then
MessageBox.Show("Form Exists")
Else
frm = new Form1
frm.ShowDialog()
End If

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2

P: n/a
Thanx for that.. Perhaps I should have explained better.

The menu system I have works on an XML file that contains the menu items,
along with dll names, class names and entry points - I create the object
through reflection and then start up a new thread to call it. I don't
keep track of the threads after I've started them off.

What I really want to do is know whether any forms started by these threads
are currently still running before I close the menu system down - i.e I
don't want the menu system closed whilst the application is running.

Maybe I should be searching for threads rather than forms?

Regards
Simon
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
A very simple example:

Dim frm as Form1

If Not (frm Is Nothing) Then
MessageBox.Show("Form Exists")
Else
frm = new Form1
frm.ShowDialog()
End If

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #3

P: n/a
Hi Simon,

Herez a thought -

When your threads create a form you could add it to a collection and on
closing the form remove it from the collection. So your collection would have
a list of open forms and you could iterate the collection to see if it has
any forms before closing the app.

VB.NET does not have an inbuilt Forms collection, but you could create a
class that behaves like a collection. Check out this link for some sample
code for the same.

http://www.dotnet247.com/247referenc...21/107856.aspx

HTH
Nov 21 '05 #4

P: n/a
Sarika

Thanks for the thought, whilst this would be a little re-engineering of my
application to get working, I think I might be able to do the same with the
threads that I am creating - If I add each thread to a collection as I start
it up, then I can iterate through the collection at a later point and check
to see that all the threads have exited?

Regards
Simon
"Sarika" <Sa****@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
Hi Simon,

Herez a thought -

When your threads create a form you could add it to a collection and on
closing the form remove it from the collection. So your collection would
have
a list of open forms and you could iterate the collection to see if it has
any forms before closing the app.

VB.NET does not have an inbuilt Forms collection, but you could create a
class that behaves like a collection. Check out this link for some sample
code for the same.

http://www.dotnet247.com/247referenc...21/107856.aspx

HTH

Nov 21 '05 #5

P: n/a
Yes I think that should work too.
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.