I did it this way once, I hope it helps:
bool createdNew;
Mutex m = new Mutex(true, "myApp", out createdNew);
if (!createdNew)
{
// myApp is already running...
MessageBox.Show("myApp is already running!", "Multiple Instances");
return;
}
More Related Contents:
- What is the correct way to create a single-instance WPF application?
- What is a good pattern for using a Global Mutex in C#?
- Concurrent HashSet in .NET Framework?
- Is using a Mutex to prevent multiple instances of the same program from running safe?
- What are the differences between various threading synchronization options in C#?
- Why doesn’t Mutex get released when disposed?
- Using string as a lock to do thread synchronization
- Synchronizing 2 processes using interprocess synchronizations objects – Mutex or AutoResetEvent
- Increase c# list performance
- Parsing CSV files in C#, with header
- Turn on/off monitor
- Do C# Timers elapse on a separate thread?
- Format of the initialization string does not conform to specification starting at index 0
- What’s the difference between X = X++; vs X++;?
- How to send text to Notepad in C#/Win32?
- How to filter Directory.EnumerateFiles with multiple criteria?
- What requirement was the tuple designed to solve?
- WIN32_Processor::Is ProcessorId Unique for all computers
- How to set enum to null
- Accessing Office Word object model through asp.net results in “failed due to the following error: 80070005 Access is denied.”
- DataGrid get selected rows’ column values
- Get table-data from table-name in LINQ DataContext
- Choose one of many Internet connections for an application
- Who should call Dispose on IDisposable objects when passed into another object?
- Convert RGB color to CMYK?
- The given key was not present in the dictionary. Which key?
- How to deserialize only part of an XML document in C#
- Overriding Extension Methods
- ASP.NET 5 Authorize against two or more policies (OR-combined policy)
- C# how to use WM_GETTEXT / GetWindowText API / Window Title