473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Stop two instances of a C# app running

I am sure this question has been asked many times before but can someone
suggest a method of stopping two instances of a C# app running at the same
time ?

Preferably I would like an attempt to invoke a second instance to bring the
first instance to the top.

Thanks.

Jon.
May 8 '06 #1
6 1580
"Bishman" <jo*************@btinternet.com> wrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
I am sure this question has been asked many times before but can someone
suggest a method of stopping two instances of a C# app running at the same
time ?
You can create named Mutex object in the app instance and then check with
other instances of the program if that mutex is created. If there is no
mutex - then the application is the first, otherwise it is other instance
( 2-nd ).
Preferably I would like an attempt to invoke a second instance to bring
the first instance to the top.


After second instance got knew that there is already an instance of the app
running it can search for its window ( maybe via win32 FindWindow(...) ),
bring that window to front and then finish execution.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
May 8 '06 #2
Hi,

"Bishman" <jo*************@btinternet.com> wrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
I am sure this question has been asked many times before but can someone
suggest a method of stopping two instances of a C# app running at the same
time ?


You are right, this has been asked several times before, a qick search in
google would have get you lot of posts:

http://groups.google.com/groups/sear...ublic.dotnet.*


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
May 10 '06 #3
OK - Point taken.....

Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uz**************@TK2MSFTNGP04.phx.gbl...
Hi,

"Bishman" <jo*************@btinternet.com> wrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
I am sure this question has been asked many times before but can someone
suggest a method of stopping two instances of a C# app running at the same
time ?


You are right, this has been asked several times before, a qick search in
google would have get you lot of posts:

http://groups.google.com/groups/sear...ublic.dotnet.*


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

May 10 '06 #4
This is boilerplate! Can't we make this a project setting and be done with
it?

-Eric
May 15 '06 #5
Here here....
"Eric Cadwell" <ec******@com.com> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...
This is boilerplate! Can't we make this a project setting and be done with
it?

-Eric

May 15 '06 #6
I submitted it as a suggestion to MS. I liked this feature of VB6.
I found an example on code project - 100,000 views! I'd say people are
asking for this alot.

http://www.codeproject.com/vb/net/si...select=1101174
May 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rahul | last post by:
Hi. I am part of a group in my univ where we organize a programming contest. In this contest we have a UDP based server. The server simulates a game and each contestant is to develop a team of...
6
by: JT | last post by:
is it possible to somehow "jump out of" an ASP page that is executed from another page via the Server.Execute method? on the page being executed i have several instances where i need to stop the...
16
by: ThunderMusic | last post by:
Hi, My app does not stop whan I click on the form. I mean, the form is closing, but the process keeps running in the task manager. So I figured there are memory leaks or some object's process...
2
by: Adrian MacNair | last post by:
Hi I need some help if anyone can understand my crap javascript. The problem is that after the slideshow ends (reaches the end of array) it should stop, but the timeout doesn't clear and I can see...
3
by: Robert | last post by:
We have several serviced components written in .NET 1.1. Using Visual Studio, we have an installer project that creates an installer for them. The components are installed properly into the GAC...
4
by: PalB | last post by:
How to stop running multiple instances of my App in C#? Thanx
4
by: tommydkat | last post by:
Well, I've finally gotten UDB 8.2 FixPak 3 up and running on my HP-UX 11i system, thanks to Mr McBride and IBM support. :) I created a 32-bit instance and that's running just fine. However, I...
3
by: Michel | last post by:
Hi, I wrote an app in .Net and I whant only 1 instance of this app open for the user; the user open my app, do some works and try to open another instance of my app, I whant to show a message to...
8
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to get a list of SQL Server Instances thru a VB.NET application. I have tried GetDataSource and SMO. I have also tried using ListSQLSvr.exe from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.