Compact Framework - Problem with Process.Start
-
Hi, I am having a strange problem when starting a process on a Windows Mobile based device. RepsApp is the entry point for the application. AppHandler is essentially a class that is used to maintain a bunch of global variables.
public class RepsApp
{
static void Main()
{
AppHandler.frmMain = new FormMain();
AppHandler.frmMain.ControlBox = true;
AppHandler.frmMain.MinimizeBox = false;
AppHandler.frmMain.FormBorderStyle = FormBorderStyle.FixedSingle;
Application.Run(AppHandler.frmMain);if (AppHandler.GetUpdates) { int processID = Process.GetCurrentProcess().Id; Process p = new Process(); p.StartInfo.FileName = Path.Combine(AppHandler.GetAppPath(), "AppUpdater.exe"); p.StartInfo.Arguments = string.Format("{0} {1}", processID, true); p.Start(); } Application.Exit(); }
}
In the MainForm class I simply set AppHandler.GetUpdates to True and close the form
public class FormMain : System.Windows.Forms.Form
{
private void menuItemGetUpdates_Click(object sender, EventArgs e)
{
AppHandler.GetUpdates = true;
this.Close();
}
}When the MainForm closes : if AppHandler.GetUpdates is True the main application stays in memory after it launchs the AppUpdater process. if AppHandler.GetUpdates is False the main application closes as expected. Is there any reason why calling Process.Start would prevent the main application from closing? Thanks, David
-
Hi, I am having a strange problem when starting a process on a Windows Mobile based device. RepsApp is the entry point for the application. AppHandler is essentially a class that is used to maintain a bunch of global variables.
public class RepsApp
{
static void Main()
{
AppHandler.frmMain = new FormMain();
AppHandler.frmMain.ControlBox = true;
AppHandler.frmMain.MinimizeBox = false;
AppHandler.frmMain.FormBorderStyle = FormBorderStyle.FixedSingle;
Application.Run(AppHandler.frmMain);if (AppHandler.GetUpdates) { int processID = Process.GetCurrentProcess().Id; Process p = new Process(); p.StartInfo.FileName = Path.Combine(AppHandler.GetAppPath(), "AppUpdater.exe"); p.StartInfo.Arguments = string.Format("{0} {1}", processID, true); p.Start(); } Application.Exit(); }
}
In the MainForm class I simply set AppHandler.GetUpdates to True and close the form
public class FormMain : System.Windows.Forms.Form
{
private void menuItemGetUpdates_Click(object sender, EventArgs e)
{
AppHandler.GetUpdates = true;
this.Close();
}
}When the MainForm closes : if AppHandler.GetUpdates is True the main application stays in memory after it launchs the AppUpdater process. if AppHandler.GetUpdates is False the main application closes as expected. Is there any reason why calling Process.Start would prevent the main application from closing? Thanks, David
hi, iam not sure if that could help.., you set the current ProcessID from the running app at the arguemnts. don't know what your AppUpdater internal do with the ProcessID but maybe it supsends the thread on the processid so you "main" application could not close ?!? greetz