Forms Dispose while being referenced!

G

Guest

I'm currently developing a CF app on Windows Mobile CE and VB.NET. The app is
working fine, well that is until you minimize it. It appears the GC kicks in
and decides to collect my forms! so when I return the screens are blank. Some
background on the technique I'm using might be helpful.

To make maintenance easier and to also provide a easier way to combine UI
elements. I am dynamically loading Forms (basically treating them as a
control - which seems to work fine given we don't have a user control). I'll
assign the parent of the dynamic form to a design time placed panel. This all
works as stated, except when the forms are minimized.

I've tried the following:
Adding the forms the the panel's controls collection. Same effect as setting
Forms parent to the panel.

Putting the forms into both module level hashtables and shared hashtables.
Hoping they wouldn't get collected as they are being referenced. Result -
didn't work.

Next, I found that I could trap the closing event of the form. I then
prevented the close from happening if the app is in a minimzed state. Result:
Works! well for awhile - if you maximise the form for say 30 secs it seems
ok. However, having the form in a minimized state for a longer period kills
the app!

This is pretty much a show stopper for the app I'm working on, so any help
would be greatly appreciated.

Regards
Garry McGlennon
 
G

Guest

So it isn't actually the GC which is trying to close your forms, it is the
OS. Your best option if the OS is trying to close your forms is to let it do
so, take note that your form was closed and then recreate it later when you
need to show it again.
-Noah Falk
 

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