Hi

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

Thanks

Regards

Re: Single instance app by rowe_newsgroups

rowe_newsgroups
Tue Feb 12 09:37:38 CST 2008

On Feb 12, 10:28 am, "John" <J...@nospam.infovis.co.uk> wrote:
> 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]

Re: Single instance app by zacks

zacks
Tue Feb 12 09:56:50 CST 2008

On Feb 12, 10:37=A0am, rowe_newsgroups <rowe_em...@yahoo.com> wrote:
> On Feb 12, 10:28 am, "John" <J...@nospam.infovis.co.uk> wrote:
>
> > Hi
>
> > Is there a way to ensure that an app is only run once and if it is run t=
wice
> > 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]

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.

So in that situation I guess you would have to resort to using a mutex
or some other method to ensure a single instace app.

Re: Single instance app by John

John
Tue Feb 12 09:57:07 CST 2008

Hi

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

Thanks for your help.

Regards

"rowe_newsgroups" <rowe_email@yahoo.com> wrote in message
news:d8062318-df2b-4aa8-95e8-a4cdc0db9bcd@h11g2000prf.googlegroups.com...
> On Feb 12, 10:28 am, "John" <J...@nospam.infovis.co.uk> wrote:
>> 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]



Re: Single instance app by Shuja

Shuja
Tue Feb 12 10:36:46 CST 2008

There is no need for Application.Quit. 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.BringToForeground = True"
in the same event handler.

Regards,
Shuja

"John" <John@nospam.infovis.co.uk> wrote in message
news:#tIwq$YbIHA.4712@TK2MSFTNGP05.phx.gbl...
> Hi
>
> Thanks for that. I need to quit the app as soon as it starts but
> Application.Quit is not available in
> Sub MyApplication_StartupNextInstance event. What can I do to quit the app
> as soon as it starts the second time?
>
> Thanks for your help.
>
> Regards
>
> "rowe_newsgroups" <rowe_email@yahoo.com> wrote in message
> news:d8062318-df2b-4aa8-95e8-a4cdc0db9bcd@h11g2000prf.googlegroups.com...
>> On Feb 12, 10:28 am, "John" <J...@nospam.infovis.co.uk> wrote:
>>> 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]
>
>

Re: Single instance app by Herfried

Herfried
Tue Feb 12 11:05:03 CST 2008

<zacks@construction-imaging.com> schrieb:
>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.Threading.Mutex' to prevent multiple instances:

FAQ for the microsoft.public.languages.csharp newsgroup
<URL:http://www.yoda.arachsys.com/csharp/faq/#one.application.instance>

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

Re: Single instance app by Scott

Scott
Tue Feb 12 18:23:13 CST 2008

>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".



Re: Single instance app by Herfried

Herfried
Tue Feb 12 18:44:02 CST 2008

"Scott M." <smar@nospam.nospam> schrieb:
> >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/>