Click here to Skip to main content
15,914,225 members
Home / Discussions / C#
   

C#

 
GeneralRe: connecting to a remote machine that is not part of your network Pin
Stephan Samuel2-Jun-06 10:34
Stephan Samuel2-Jun-06 10:34 
GeneralRe: connecting to a remote machine that is not part of your network Pin
sopheapteng2-Jun-06 11:03
sopheapteng2-Jun-06 11:03 
GeneralRe: connecting to a remote machine that is not part of your network Pin
Stephan Samuel2-Jun-06 11:30
Stephan Samuel2-Jun-06 11:30 
QuestionBase Class Library Samples Pin
Robert M Greene2-Jun-06 7:00
Robert M Greene2-Jun-06 7:00 
GeneralRe: Base Class Library Samples Pin
Office Lineman2-Jun-06 8:17
Office Lineman2-Jun-06 8:17 
GeneralRe: Base Class Library Samples Pin
Robert M Greene2-Jun-06 8:35
Robert M Greene2-Jun-06 8:35 
AnswerRe: Base Class Library Samples Pin
Office Lineman2-Jun-06 9:09
Office Lineman2-Jun-06 9:09 
QuestionSingle Instance Application Pin
EyeOfTheSky2-Jun-06 6:26
EyeOfTheSky2-Jun-06 6:26 
Hi everyone,
I am trying to create a single instance application. What I have been able to do so far is to prevent more than one instance of the application to run (I have used a Mutex). However, what I would like to do is to bring the already running application to the foreground whenever someone is trying to run another instance of the application. In other words, if I already have an instance of the application running, and I try to run the executable again, I would like to see the running application pop up in front of me.

Here is the code that I have so far:

static class Program
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
// These variables will be used to provide single instance functionality
bool blnExclusive = false; // must be initialized
Mutex SingleInstanceMutex = null; // must be initialized


// Try to create mutex
try
{
SingleInstanceMutex = new Mutex(true, "My Mutex", out blnExclusive);
}

// Catch exception and exit application
catch
{
Application.Exit();
}

// If no other instances exist, start new application
if (blnExclusive)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new myFrm());
GC.KeepAlive(SingleInstanceMutex);
}

else
{
//TODO: try to bring existing instance to foreground

}
}
}

Any help is appreciated, thanks.
AnswerRe: Single Instance Application Pin
Ravi Bhavnani2-Jun-06 6:53
professionalRavi Bhavnani2-Jun-06 6:53 
QuestionC# Threading Pin
AlEvanGe2-Jun-06 6:07
AlEvanGe2-Jun-06 6:07 
AnswerRe: C# Threading Pin
led mike2-Jun-06 6:53
led mike2-Jun-06 6:53 
AnswerRe: C# Threading Pin
Ravi Bhavnani2-Jun-06 6:56
professionalRavi Bhavnani2-Jun-06 6:56 
Questionhighlight the selected row in gridview Pin
kjosh2-Jun-06 5:49
kjosh2-Jun-06 5:49 
QuestionPlease Help Very Urgent... Pin
YoungJoe2-Jun-06 5:46
YoungJoe2-Jun-06 5:46 
AnswerRe: Please Help Very Urgent... Pin
Stephan Samuel2-Jun-06 5:50
Stephan Samuel2-Jun-06 5:50 
AnswerRe: Please Help Very Urgent... Pin
Elina Blank2-Jun-06 9:37
sitebuilderElina Blank2-Jun-06 9:37 
QuestionCreate xml ini file Pin
donkaiser2-Jun-06 5:06
donkaiser2-Jun-06 5:06 
AnswerRe: Create xml ini file Pin
stancrm2-Jun-06 5:13
stancrm2-Jun-06 5:13 
GeneralRe: Create xml ini file Pin
Stephan Samuel2-Jun-06 5:46
Stephan Samuel2-Jun-06 5:46 
QuestionConvert HTML into XML Pin
Felipe Dalorzo2-Jun-06 4:58
Felipe Dalorzo2-Jun-06 4:58 
AnswerRe: Convert HTML into XML Pin
Ravi Bhavnani2-Jun-06 6:59
professionalRavi Bhavnani2-Jun-06 6:59 
AnswerRe: Convert HTML into XML Pin
Eran Aharonovich9-Jul-06 7:34
Eran Aharonovich9-Jul-06 7:34 
QuestionRegular Expressions Pin
reshsilk2-Jun-06 4:33
reshsilk2-Jun-06 4:33 
AnswerRe: Regular Expressions Pin
User 66582-Jun-06 4:40
User 66582-Jun-06 4:40 
GeneralRe: Regular Expressions Pin
reshsilk2-Jun-06 5:06
reshsilk2-Jun-06 5:06 

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.