Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. C# - Problems with Process.Start

C# - Problems with Process.Start

Scheduled Pinned Locked Moved Mobile
csharpperformancehelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dlarkin77
    wrote on last edited by
    #1

    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

    E A 2 Replies Last reply
    0
    • D dlarkin77

      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

      E Offline
      E Offline
      Enobong Adahada
      wrote on last edited by
      #2

      Post the question again in the C# forum n someone will answer.

      1 Reply Last reply
      0
      • D dlarkin77

        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

        A Offline
        A Offline
        Ashwini K Singh
        wrote on last edited by
        #3

        What AppUpdater.exe is doing with Process ID of calling application, :doh:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups