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. Launching application from another application

Launching application from another application

Scheduled Pinned Locked Moved C#
question
6 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.
  • Z Offline
    Z Offline
    zaboboa
    wrote on last edited by
    #1

    Hello, I have the following: private void button_Click(object sender, EventArgs e) { this.demoThread = new Thread (new ThreadStart (this.ThreadProcSafe)); this.demoThread.Start(); } private void ThreadProcSafe () { MyReference.Form2 form2 = new Form2(); Application.Run(form2); } I was just wondering if that's the proper way to do it? It must be a separate thread, but I just don't know if doing it the way I am doing it is good programming practice. Is there information regarding launching applications on a separate threads. Sort of showing top-level windows in it's own process thread. Thank you.

    J 1 Reply Last reply
    0
    • Z zaboboa

      Hello, I have the following: private void button_Click(object sender, EventArgs e) { this.demoThread = new Thread (new ThreadStart (this.ThreadProcSafe)); this.demoThread.Start(); } private void ThreadProcSafe () { MyReference.Form2 form2 = new Form2(); Application.Run(form2); } I was just wondering if that's the proper way to do it? It must be a separate thread, but I just don't know if doing it the way I am doing it is good programming practice. Is there information regarding launching applications on a separate threads. Sort of showing top-level windows in it's own process thread. Thank you.

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      You want a new process, not a new thread. System.Diagnostics.Process.Start(@"C:\MyApp.exe");

      Z 1 Reply Last reply
      0
      • J J4amieC

        You want a new process, not a new thread. System.Diagnostics.Process.Start(@"C:\MyApp.exe");

        Z Offline
        Z Offline
        zaboboa
        wrote on last edited by
        #3

        I load the other reference in the form of .dll. So how would I call that as another process? Other thing, my main window, that is launches the other processes, will show all the windows open in the window menu, and the only way to interact with the other windows is by using the worker threads. Thank you.

        J 1 Reply Last reply
        0
        • Z zaboboa

          I load the other reference in the form of .dll. So how would I call that as another process? Other thing, my main window, that is launches the other processes, will show all the windows open in the window menu, and the only way to interact with the other windows is by using the worker threads. Thank you.

          J Offline
          J Offline
          Jim Bennett
          wrote on last edited by
          #4

          Read up on .Net app domains. What are you trying to do? Do you have to have a separate application or process running? Ok, only having one running app makes life easier so that you can use object references and all that. The app is already running, just show some forms without using threads. The UI is the UI. It should be thin. You don't have to model the UI after the physical implementation details (threads). Use the minimal amount of threads to do some work so that the UI isn't hung up waiting for a calcuation to finish (the UI remains snappy). When the thread is done, update the form UI to present it to the user. A form should not have much code in it, it is just the presentation to the user. Lookup BeginInvoke() on CP and google. If you really want to have some fun, you could use .Net Remoting to talk between apps. This way you can have independent apps up and they can talk to each other. Usually this is done when you have the exes running on separate machines. Jim

          Z 1 Reply Last reply
          0
          • J Jim Bennett

            Read up on .Net app domains. What are you trying to do? Do you have to have a separate application or process running? Ok, only having one running app makes life easier so that you can use object references and all that. The app is already running, just show some forms without using threads. The UI is the UI. It should be thin. You don't have to model the UI after the physical implementation details (threads). Use the minimal amount of threads to do some work so that the UI isn't hung up waiting for a calcuation to finish (the UI remains snappy). When the thread is done, update the form UI to present it to the user. A form should not have much code in it, it is just the presentation to the user. Lookup BeginInvoke() on CP and google. If you really want to have some fun, you could use .Net Remoting to talk between apps. This way you can have independent apps up and they can talk to each other. Usually this is done when you have the exes running on separate machines. Jim

            Z Offline
            Z Offline
            zaboboa
            wrote on last edited by
            #5

            Thank you for your reply. I decided to use BeginInvoke, insted of creating a new Thread. What I am trying to do, is to have a main window application, which basically will have a list of applications to run. These apps are coded in C# as well, so I have to add them as references to the main window application. If the user launches one of these apps, I needed to be independent, because if that app displays a dialog box, it should only lock the access to the parent of that dialog box (built in), but not the access to the main window application, or other apps that might of being launch from the main window application. I hope that creates a picture for you. Thank you again

            J 1 Reply Last reply
            0
            • Z zaboboa

              Thank you for your reply. I decided to use BeginInvoke, insted of creating a new Thread. What I am trying to do, is to have a main window application, which basically will have a list of applications to run. These apps are coded in C# as well, so I have to add them as references to the main window application. If the user launches one of these apps, I needed to be independent, because if that app displays a dialog box, it should only lock the access to the parent of that dialog box (built in), but not the access to the main window application, or other apps that might of being launch from the main window application. I hope that creates a picture for you. Thank you again

              J Offline
              J Offline
              Jim Bennett
              wrote on last edited by
              #6

              If you are going to launch exe's, then Process.Start (as previously mentioned) is what you want to call. Personally, I would not be launching exe's, but rather referencing the assemblies and creating an object which does what the Main entry point does for each "app." This way you can setup communication (if you want to down the road) since everything is running under the same app domain. If there is a modal dialog, then well, shouldn't the user be held hostage in order to reconcile the OK/Cancel dialog :) Jim

              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