Single instance app

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Single instance app

    Hi

    Is there a way to ensure that an app is only run once and if it is run twice
    it terminates?

    Thanks

    Regards


  • John

    #2
    Re: Single instance app

    Hi

    Thanks for that. I need to quit the app as soon as it starts but
    Application.Qui t is not available in
    Sub MyApplication_S tartupNextInsta nce event. What can I do to quit the app
    as soon as it starts the second time?

    Thanks for your help.

    Regards

    "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
    news:d8062318-df2b-4aa8-95e8-a4cdc0db9bcd@h1 1g2000prf.googl egroups.com...
    On Feb 12, 10:28 am, "John" <J...@nospam.in fovis.co.ukwrot e:
    >Hi
    >>
    >Is there a way to ensure that an app is only run once and if it is run
    >twice
    >it terminates?
    >>
    >Thanks
    >>
    >Regards
    >
    Look at your project properties, I do believe there is a check box
    there.
    >
    Also, did you even search for this before posting?
    >
    Thanks,
    >
    Seth Rowe [MVP]

    Comment

    • Shuja Ali Zaroo

      #3
      Re: Single instance app

      There is no need for Application.Qui t. The .NET Runtime will take care of
      that once you have checked the Make Single Instance Application. You can
      even bring the previous instance to front using "e.BringToForeg round = True"
      in the same event handler.

      Regards,
      Shuja

      "John" <John@nospam.in fovis.co.ukwrot e in message
      news:#tIwq$YbIH A.4712@TK2MSFTN GP05.phx.gbl...
      Hi
      >
      Thanks for that. I need to quit the app as soon as it starts but
      Application.Qui t is not available in
      Sub MyApplication_S tartupNextInsta nce event. What can I do to quit the app
      as soon as it starts the second time?
      >
      Thanks for your help.
      >
      Regards
      >
      "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
      news:d8062318-df2b-4aa8-95e8-a4cdc0db9bcd@h1 1g2000prf.googl egroups.com...
      >On Feb 12, 10:28 am, "John" <J...@nospam.in fovis.co.ukwrot e:
      >>Hi
      >>>
      >>Is there a way to ensure that an app is only run once and if it is run
      >>twice
      >>it terminates?
      >>>
      >>Thanks
      >>>
      >>Regards
      >>
      >Look at your project properties, I do believe there is a check box
      >there.
      >>
      >Also, did you even search for this before posting?
      >>
      >Thanks,
      >>
      >Seth Rowe [MVP]
      >
      >

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Single instance app

        <zacks@construc tion-imaging.comschr ieb:
        >That is only applicable if you have the "Enable Visual Styles"
        >checkbox on. I don't know about you, but I prefer to configure VB.NET
        >apps the same way C#.NET does by default, and have the startup object
        >as SubMain, enable visual styles there manually and open the main form
        >with an Application.Run call.
        You could use 'System.Threadi ng.Mutex' to prevent multiple instances:

        FAQ for the microsoft.publi c.languages.csh arp newsgroup
        <URL:http://www.yoda.arachs ys.com/csharp/faq/#one.applicatio n.instance>

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        • Scott M.

          #5
          Re: Single instance app

          >That is only applicable if you have the "Enable Visual Styles"
          >checkbox on.
          Are you sure about that? I thought it was available if you've chosen to
          "Enable Application Frameworks".


          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Single instance app

            "Scott M." <smar@nospam.no spamschrieb:
            That is only applicable if you have the "Enable Visual Styles"
            >>checkbox on.
            >
            Are you sure about that? I thought it was available if you've chosen to
            "Enable Application Frameworks".
            C# doesn't support the application framework.

            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

            Comment

            Working...