471,605 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

Running an application more than once

Any ideas how to stop the user opening an app more than once? So there is not
more than one instance running at the same time.

Thanks.
Feb 17 '06 #1
4 3409
James,

See my response in this thread for information on the
WindowsApplicationBase class, which you can use to do this:

http://groups.google.com/group/micro...2d86fcc6e071fe

There is also a solution there for .NET 1.1 and before as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"James L" <Ja****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Any ideas how to stop the user opening an app more than once? So there is
not
more than one instance running at the same time.

Thanks.

Feb 17 '06 #2
You can also look at my article at
http://www.dalepreston.com/Blog/2005...-run-once.html for an
alternative method that will send any command line arguments on the second
instance to the first instance before shutting down the second instance.

There's one more good solution I'd like to suggest but I can't find it. It
is from a regular on the groups that has a site with a great Graphics
namespace help too. I can't find the site but if you can, his solution is
very simple if you don't need to do the message passing that my solution does.

HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA
"James L" wrote:
Any ideas how to stop the user opening an app more than once? So there is not
more than one instance running at the same time.

Thanks.

Feb 17 '06 #3
"James L" <Ja****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Any ideas how to stop the user opening an app more than once? So there is
not
more than one instance running at the same time.


In v1.x I used to do this with a Mutex object. I've not looked at how to do
this in v2 yet, but I believe your question has already been answered by
Nicholas and Dale.

Occasionally, just occasionally, I sometimes yearn for VB's simplicity...
App.PrevInstance was a classic, wasn't it...? :-)
Feb 18 '06 #4
Actually, I started using the Mutex method in VB apps years ago because
App.PreviousInstance was not reliable. It was common for applications to be
able to be run twice because of timing issues.

My original inspiration for the Mutex method was an article on mvps.org
years ago that described more technical details of what caused the problems
when using App.PreviousInstance. I don't remember that far back too clearly
and the site has changed formats so the old information isn't there anymore.

--
Dale Preston
MCAD C#
MCSE, MCDBA
"Mark Rae" wrote:
"James L" <Ja****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Any ideas how to stop the user opening an app more than once? So there is
not
more than one instance running at the same time.


In v1.x I used to do this with a Mutex object. I've not looked at how to do
this in v2 yet, but I believe your question has already been answered by
Nicholas and Dale.

Occasionally, just occasionally, I sometimes yearn for VB's simplicity...
App.PrevInstance was a classic, wasn't it...? :-)

Feb 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Oenone | last post: by
20 posts views Thread by Bradley | last post: by
10 posts views Thread by sebastian nielsen | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.