T
Trevor
What is the best practice for Form navigation for a Compact Framework
application? I have implemented a simple function in Program.cs to switch
the screens (see below for implementation). I have noticed if I close my
application through Start > Settings > Memory > Running Applications, all of
the Forms close, but the process remains running and I have to kill it using
Remote Process Viewer.
I am starting out the program with a Application.Run(new LogonForm()) and
then I am calling the function below to show new screens as the application
runs. I have noticed the program only keeps running after I switch to a
second form. That is, if I close the LogonForm using Running Applications,
the process exits cleanly as long as I don't switch to a second form using
my function. I imagine this means I am not doing something the preferred
way. I decided to use Show instead of ShowDialog because I have no need to
keep the LogonForm active for the duration of the program.
Here is the function I am using to switch screens:
public static void ShowScreen(Form newFrm, Form oldFrm)
{
if (newFrm != null)
newFrm.Show();
else
throw new ArgumentNullException();
if (oldFrm != null)
{
oldFrm.Hide();
oldFrm = null;
}
else
throw new ArgumentNullException();
}
I call it like this when I want to switch screens:
Program.ShowScreen(new ManifestForm(), this);
application? I have implemented a simple function in Program.cs to switch
the screens (see below for implementation). I have noticed if I close my
application through Start > Settings > Memory > Running Applications, all of
the Forms close, but the process remains running and I have to kill it using
Remote Process Viewer.
I am starting out the program with a Application.Run(new LogonForm()) and
then I am calling the function below to show new screens as the application
runs. I have noticed the program only keeps running after I switch to a
second form. That is, if I close the LogonForm using Running Applications,
the process exits cleanly as long as I don't switch to a second form using
my function. I imagine this means I am not doing something the preferred
way. I decided to use Show instead of ShowDialog because I have no need to
keep the LogonForm active for the duration of the program.
Here is the function I am using to switch screens:
public static void ShowScreen(Form newFrm, Form oldFrm)
{
if (newFrm != null)
newFrm.Show();
else
throw new ArgumentNullException();
if (oldFrm != null)
{
oldFrm.Hide();
oldFrm = null;
}
else
throw new ArgumentNullException();
}
I call it like this when I want to switch screens:
Program.ShowScreen(new ManifestForm(), this);