C# - Problems with Process.Start
-
Hi, I am having a strange problem when starting a process. 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. 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
Post the question again in the C# forum n someone will answer.
-
Hi, I am having a strange problem when starting a process. 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
What AppUpdater.exe is doing with Process ID of calling application, :doh: