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. how to cause current application to close upon arrival of new updated application ?

how to cause current application to close upon arrival of new updated application ?

Scheduled Pinned Locked Moved C#
csharpvisual-studiotoolstutorialquestion
5 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.
  • S Offline
    S Offline
    shabya
    wrote on last edited by
    #1

    hello, i wrote an application in c# that starts automaticaly when computer starts. i allready have code that prevents the application from running more than once as follows:

    static void Main()
    {
    Boolean firstInstance = false;
    string safeName = "xxx";
    Mutex mutex = new Mutex(true, safeName, out firstInstance);
    if (!firstInstance) return;
    }

    now when i publish a new version (i set the revision to increase automaticaly) and run the setup file all is fine but the old application still remains. i get two copies running , one new and one old. is there a way to tell the old version to close ? like an external event? i am using only visual studio tools. thanks in advance avi

    N 1 Reply Last reply
    0
    • S shabya

      hello, i wrote an application in c# that starts automaticaly when computer starts. i allready have code that prevents the application from running more than once as follows:

      static void Main()
      {
      Boolean firstInstance = false;
      string safeName = "xxx";
      Mutex mutex = new Mutex(true, safeName, out firstInstance);
      if (!firstInstance) return;
      }

      now when i publish a new version (i set the revision to increase automaticaly) and run the setup file all is fine but the old application still remains. i get two copies running , one new and one old. is there a way to tell the old version to close ? like an external event? i am using only visual studio tools. thanks in advance avi

      N Offline
      N Offline
      Navneet Hegde
      wrote on last edited by
      #2

      Hi! Do you mean to say that during updated installation you SETUP should remove previous installation. Thanks!

      Develop2Program & Program2Develop

      S 1 Reply Last reply
      0
      • N Navneet Hegde

        Hi! Do you mean to say that during updated installation you SETUP should remove previous installation. Thanks!

        Develop2Program & Program2Develop

        S Offline
        S Offline
        shabya
        wrote on last edited by
        #3

        no no navneet hegde, i ment that a previous program is still running, now a new program needs to run instead of it so how will it end the process of the previous program ? i dont want the old program and the new program to run but only the new one. after the installation of the new program finishes , the old program closes and the new program takes it place.. i seen it done in famous apps , i wanna do it too... thanks :)

        N 1 Reply Last reply
        0
        • S shabya

          no no navneet hegde, i ment that a previous program is still running, now a new program needs to run instead of it so how will it end the process of the previous program ? i dont want the old program and the new program to run but only the new one. after the installation of the new program finishes , the old program closes and the new program takes it place.. i seen it done in famous apps , i wanna do it too... thanks :)

          N Offline
          N Offline
          Navneet Hegde
          wrote on last edited by
          #4

          Hi! Your new Application starts. In Main get the collection of all the running processes. Iterating it you get your running process object. Compare it's build with this process build. If it's greater than kill the previous process and continue with this process. Else kill this process. Thanks!

          Develop2Program & Program2Develop

          S 1 Reply Last reply
          0
          • N Navneet Hegde

            Hi! Your new Application starts. In Main get the collection of all the running processes. Iterating it you get your running process object. Compare it's build with this process build. If it's greater than kill the previous process and continue with this process. Else kill this process. Thanks!

            Develop2Program & Program2Develop

            S Offline
            S Offline
            shabya
            wrote on last edited by
            #5

            ok , thanks i shall try that :)

            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