Search Unity

Application force single instance

Discussion in 'Editor & General Support' started by greg424242, Apr 12, 2018.

  1. greg424242

    greg424242

    Joined:
    Sep 27, 2017
    Posts:
    7
    Hello,

    I wonder if it's possible to detect my application launch, when it is already launched.
    And retrieve the new argument past in parameters.

    Actually the force single instance behaviour cannot do this.

    Thank you,
     
  2. greg424242

    greg424242

    Joined:
    Sep 27, 2017
    Posts:
    7
    no one ?
     
  3. ljwolfinger58

    ljwolfinger58

    Joined:
    Jul 23, 2021
    Posts:
    1
    Yes it is impossible
     
  4. ChernyshevDS

    ChernyshevDS

    Joined:
    Sep 28, 2020
    Posts:
    1
    Necroposting, but it IS possible. However, just the detection of second instance and arguments passing are on rather different complexity levels.

    Basically, the second instance of the app should detect some system-wide shared object. E.g., first app instance may open some file with exclusive write permissions, and the second app instance may detect that it can not do it. Or it may use named system mutex for the same purpose. So running only one app instance is not that hard.

    However to pass arguments from the second instance to first one there should be some kind of interprocess communication. One can listen on predefined UDP port, or use named pipes, or poll memory mapped file, or... you name it.