Single Instance Windows Form Application in C#
Single Instance Windows Form Application in C# :It is possible to block new instances of a program using Mutex. This prevents new ones from running alongside old ones.
Incoming search terms
Single Instance Windows Form Application in C#, Single Instance Form Application in C#, C# Single Instance App With the Ability To Restore From, C# Single-Instance Windows Form, create a single instance application, c# single instance application using mutex, c# – Run single instance of an application using Mutex.
One of the most common reasons to limit the number of instances is to restrict the access to some sensitive resources.
For this purpose, we use the Mutex object. This approach can be used on all three types of desktop applications (console, winforms, WPF). A Mutex (mutual exclusion) is an object (or principle if you want) that is commonly used for synchronizing several threads when they are accessing and using the same resources. It is sort of a gate keeper that allows just one visitor to enter the code at a time.
Please check below link for more understand.
In previous articles we explained Rating Control in WPF, How to Add Google Fonts in Website, Voucher Image in ASP.NET, Sliding Panel in WPF, Tag Cloud in ASP.NET, Save and Retrieve Images From Database, Upload file without clicking on Button, Generate QR Code Image, Get Network and Local Printer List in ASP.NET, Custom Slider Control in WPF, Convert Comma Separated String to Table in SQL, Bind ListView in ASP.NET, Encrypt and Decrypt String in C#, Retrieve Dropped Stored Procedure, Function, Table in SQL, Minimum and Maximum Text Length Validation in ASP.NET, Get or Set Cursor Position in a Textarea, Vertical Image Slider in WPF, SQL Query List, etc.
Following are the steps to create single instance windows form application in c#
Create a windows forms application using C#
If you are sound with Windows Forms then you know very well how to create a windows forms application.
LEARN MORE : HOW TO CREATE WINDOWS FORMS APPLICATION IN VISUAL STUDIO 2010
static class Program
private static Mutex mutex = null;
/// The main entry point for the application.
static void Main()
//Settings for single instance app start
const string appName = "SingleInstanceApp";
mutex = new Mutex(true, appName, out createdNew);
//app is already running! Exiting the application
MessageBox.Show("Application is already running.");
//Settings for single instance app end
RUN PROJECT AND CHECK FINAL OUTPUT