Click here to Skip to main content
15,897,968 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Perfomance of application Pin
cocoonwls14-Feb-07 11:58
cocoonwls14-Feb-07 11:58 
GeneralRe: Perfomance of application Pin
Luc Pattyn14-Feb-07 12:06
sitebuilderLuc Pattyn14-Feb-07 12:06 
GeneralRe: Perfomance of application Pin
cocoonwls14-Feb-07 12:21
cocoonwls14-Feb-07 12:21 
GeneralRe: Perfomance of application Pin
Luc Pattyn14-Feb-07 12:37
sitebuilderLuc Pattyn14-Feb-07 12:37 
GeneralRe: Perfomance of application Pin
Iqbal M Khan14-Feb-07 20:09
Iqbal M Khan14-Feb-07 20:09 
AnswerRe: Perfomance of application Pin
Heath Stewart17-Feb-07 6:15
protectorHeath Stewart17-Feb-07 6:15 
QuestionProblems with getProcessesByName Pin
derbrink14-Feb-07 3:31
derbrink14-Feb-07 3:31 
AnswerRe: Problems with getProcessesByName Pin
Luc Pattyn14-Feb-07 6:51
sitebuilderLuc Pattyn14-Feb-07 6:51 
Hi,

you could create a Mutex with a name that includes your process name (in order not to interfere with other programs that might do similar things) AND the user's name
(e.g. from Environment.UserName). And then try a WaitOne on it:

string name="myProgName"+Environment.UserName;
Mutex m=new Mutex(false, name);
if (myMutex.WaitOne(1,true)) {
   ... this is my first instance
} else {
   ... I already have an instance running
}


You should keep m as a global variable so its life spans your app's life.
I typically have a class that does such singleton test before I create my main form,
hence in the static void Main() method.

PS: you could use Environment.GetCommandLineArgs()[0] to obtain your prog name
(actually its exe's file name).

Hope this helps


Luc Pattyn

QuestionFixed a window Form Pin
Parameswar Mala14-Feb-07 1:27
Parameswar Mala14-Feb-07 1:27 
AnswerRe: Fixed a window Form Pin
Heath Stewart17-Feb-07 6:25
protectorHeath Stewart17-Feb-07 6:25 
QuestionMenuItem Compact Framework [modified] Pin
danaelx14-Feb-07 1:11
danaelx14-Feb-07 1:11 
QuestionResolution Problem. Pin
Parameswar Mal14-Feb-07 1:06
Parameswar Mal14-Feb-07 1:06 
AnswerRe: Resolution Problem. Pin
Luc Pattyn14-Feb-07 6:54
sitebuilderLuc Pattyn14-Feb-07 6:54 
AnswerRe: Resolution Problem. Pin
N a v a n e e t h14-Feb-07 18:34
N a v a n e e t h14-Feb-07 18:34 
QuestionIs it possible to run a vb.net application without Visual Studio?? Pin
China-Gary13-Feb-07 12:41
China-Gary13-Feb-07 12:41 
AnswerRe: Is it possible to run a vb.net application without Visual Studio?? Pin
Pete O'Hanlon14-Feb-07 1:42
mvePete O'Hanlon14-Feb-07 1:42 
QuestionCharmap - Like control? Pin
Sebastian P.R. Gingter13-Feb-07 5:40
Sebastian P.R. Gingter13-Feb-07 5:40 
AnswerRe: Charmap - Like control? Pin
Ed.Poore14-Feb-07 6:45
Ed.Poore14-Feb-07 6:45 
AnswerRe: Charmap - Like control? Pin
Ray Cassick16-Feb-07 10:35
Ray Cassick16-Feb-07 10:35 
QuestionDoes the System.Diagnostics.Process.Kill() trigger an event? Pin
jeremy.t13-Feb-07 5:26
jeremy.t13-Feb-07 5:26 
AnswerRe: Does the System.Diagnostics.Process.Kill() trigger an event? Pin
Dave Kreskowiak13-Feb-07 6:05
mveDave Kreskowiak13-Feb-07 6:05 
QuestionProblem with Migrating from .net 1.1 to .net 2.0 Pin
VishalSharmaDev13-Feb-07 0:23
VishalSharmaDev13-Feb-07 0:23 
AnswerRe: Problem with Migrating from .net 1.1 to .net 2.0 Pin
Luc Pattyn13-Feb-07 1:57
sitebuilderLuc Pattyn13-Feb-07 1:57 
Questionhw to desply the result(output) in Console(COMMAND PROMPT) of a WINDOWS ApPLCIATION Pin
pashitech12-Feb-07 19:44
pashitech12-Feb-07 19:44 
AnswerRe: hw to desply the result(output) in Console(COMMAND PROMPT) of a WINDOWS ApPLCIATION Pin
sxbluebird12-Feb-07 22:15
sxbluebird12-Feb-07 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.