G
Guest
Hi, I would like to have some information on how to use try...catch.
I'm trying to simplify the problem in this way: imagine to have a main form
that opens another form in this way:
Form2 frm2=new Form2();
try
{
frm2.ShowDialog();
}
catch (Exception exc)
{
MessageBox.Show("Error: "+exc.Message);
}
Well, if the Form2 produce some error, this will be catched and I see my
error message but I see it just for a second and then the complete
application ends.
In some more complex situation the application crashes and I need to
soft-reset the device; and here I have another problem because all the
Windows CE devices (I'm not talking about PPC) doesn't have an hardware
soft-reset and this means that, if the operatying system crashes because of
my application, I need to hard-reset the device and I will lost everything
that is not saved on flash-disk area.
This is very dangerous for me because to restart I need to install
everything, my application, .NETCF and OpenNETCF.
To avoid this bad situation I would like to understand the better use of
try...catch structure.
In complex situation Form2 can do a lot of things and can have a lot of
functions; every one of this function can produce an error and you know that
it is difficult to control everything. Is it really necessary to put
try...catch everywhere ? Is there a limit on using an high number of
try...catch ?
I hope to have express in a clear way my problem otherwise let me know I
will try to explain it better.
Thank you in advance.
Keven Corazza
I'm trying to simplify the problem in this way: imagine to have a main form
that opens another form in this way:
Form2 frm2=new Form2();
try
{
frm2.ShowDialog();
}
catch (Exception exc)
{
MessageBox.Show("Error: "+exc.Message);
}
Well, if the Form2 produce some error, this will be catched and I see my
error message but I see it just for a second and then the complete
application ends.
In some more complex situation the application crashes and I need to
soft-reset the device; and here I have another problem because all the
Windows CE devices (I'm not talking about PPC) doesn't have an hardware
soft-reset and this means that, if the operatying system crashes because of
my application, I need to hard-reset the device and I will lost everything
that is not saved on flash-disk area.
This is very dangerous for me because to restart I need to install
everything, my application, .NETCF and OpenNETCF.
To avoid this bad situation I would like to understand the better use of
try...catch structure.
In complex situation Form2 can do a lot of things and can have a lot of
functions; every one of this function can produce an error and you know that
it is difficult to control everything. Is it really necessary to put
try...catch everywhere ? Is there a limit on using an high number of
try...catch ?
I hope to have express in a clear way my problem otherwise let me know I
will try to explain it better.
Thank you in advance.
Keven Corazza