In Windows Mobile Application, how to create only one instance of application?


I have an application I wrote in C# to be run on a windows mobile device.
The application works fine but here's a problem.

When ever I double click my application.exe, it starts a new application even if there is an existing one running. I want it so that if application.exe is already running, and user clicks to start a new application.exe, this brings up the existing application.exe without starting a new one.

Take Pocket Internet Explorer for example. When you already have IE running, and click to run IE again, this does not start a new IE application. It simply brings up the existing IE.

How can I do something like this for my application?

Thank you.

Who is Participating?
Jai STech ArchCommented:
you can use this to check

using System.Diagnostics;

write this code in your form load
            Process[] CurrentProcesses;
            CurrentProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
//instead of return you can end you application...
//this code will check whether there is another process running with the same name
            if(CurrentProcesses.GetUpperBound(0) > 0) return;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.