Using window panels instead of windows.forms

P

personificator

Hello .Net enthusiasts. I have a problem with a Mobil Application I'm
developing on the Windows CE 5 platform. The application will crash
eratically without displaying debugging info usually when loading a
separate form using show and hide methods. I placed try/catches on all
the code blocks I thought would contribute to the crash, but have not
solved the problem. I've been reading forums and have come to the
conclusion that the entire application should be using one form and
multiple windowing panels instead of loading a new form every time.
Could this be the problem, or is mine rooted much deeper? I really
would like to figure this out, so any insight would help. If I should
move all the forms into panels, what would be the best way to go about
this as each form is in a separate file.
Thank you for reading.

P.S. This is all done using .Net 2.0 Compact framework with C Sharp.

This is my current code.
Form MediaForm = new frmMediaForm();
MediaForm.Show();
this.Hide();

This what I'm thinking I need to do instead.
pnlMediaForm.Show();
pnlCurrentForm.Hide();
 
G

Guest

I disagree. Using lots of Panels inside a single Form will actually require
more memory at one time and is probably not the way to acheive what you're
after.
 
C

Christian Resma Helle

Ever looked into UserControls? When I make kiosk mode applications, I only
have one main form and everything else are UserControls. You can can always
dispose of them when you don't use them anymore
 
P

personificator

Ever looked into UserControls? When I make kiosk mode applications, I only
have one main form and everything else are UserControls. You can can always
dispose of them when you don't use them anymore

Are you actually saying to make every panel on all my other forms a
custom user control to be added, shown and hidden to the main form
individually?
That seems like a lot of work, especially when I have a lot of data
being entered and reused later on in the app, but definitely more
memory efficient then my last 2 options.
 
G

Guest

Can't see how it's more efficient memory-wise than separate Forms per
screen. When the Form is closed and disposed it's going to release
resources just like a Control would.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
P

personificator

Can't see how it's more efficient memory-wise than separate Forms per
screen. When the Form is closed and disposed it's going to release
resources just like a Control would.

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com


news:[email protected]...

My fear is that there are still controls or data referencing controls
that are used on separate forms that are preventing disposal. I
haven't found any other reason for the app just randomly crashing when
switching between forms. Would it help to put a try catch around
showing and hiding forms? What would be the exception raised? None of
the questions have been answered by the debugger, because it doesn't
happen when debugging!
Thanks for your replies.
 
G

Guest

Adding a handler for unhandled appdomain exceptions would be a good start.
Running RPM or the 3.5 profiler might be useful in tracking what objects are
still live as well. If you're having termination due to memory issues,
panels or user controls isn't going to fix it. Resolving the memory issue
is the only way.
 
S

stealthrabbi

I have a setup similar to yours... C#, .NET CF 2.0, on Windows CE. I
use multiple forms, and do not experience anything like this. What
details do you have for what is "erratically crashing"?
 
P

personificator

I have a setup similar to yours... C#, .NET CF 2.0, on Windows CE. I
use multiple forms, and do not experience anything like this. What
details do you have for what is "erratically crashing"?

Thats the thing. I don't have info to give you. This doesn't happen
during with debugging on, and I can only get it to happen on the
device. When the crash happens, it is during a form hide show. I know
at least that much, but I have not been able to throw an exception for
this. It only happens 1 time out of 100 or more, so I'm pretty much
flabbergasted at the whole issue.
 
S

Scott Gifford

[...]
My fear is that there are still controls or data referencing
controls that are used on separate forms that are preventing
disposal. I haven't found any other reason for the app just randomly
crashing when switching between forms. Would it help to put a try
catch around showing and hiding forms? What would be the exception
raised? None of the questions have been answered by the debugger,
because it doesn't happen when debugging!

I had some problems like this with event handles and an
ObjectDisposedException. A form I created would register an event
handler with a timer object, and when the form was closing
occasionally the timer event would fire, try to run the handler,
reference some part of the form that had already been disposed, and
throw an ObjectDisposedException. I solved this by making sure to
unregister any event handlers when the form is closed. I also caught
and logged an ObjectDisposedException in the application, which helped
me debug it.

Another thing that was helpful in tracking this down was using log4net
to log information about what's going on when my application is
running. Then when I had a crash, I could dig through the log and get
some idea of what was going on when it crashed.

Hope this helps,

----Scott.
 

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