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. General Programming
  3. C#
  4. Compact Framework - Problem with Process.Start

Compact Framework - Problem with Process.Start

Scheduled Pinned Locked Moved C#
performancehelpquestion
2 Posts 2 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 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

    F 1 Reply Last reply
    0
    • D dlarkin77

      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

      F Offline
      F Offline
      freakyit
      wrote on last edited by
      #2

      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

      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