> For the complete documentation index, see [llms.txt](https://docs.soraco.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soraco.co/docs/faq/how-to-prevent-a-user-from-running-multiple-instances-of-your-app.md).

# How to prevent a user from running multiple instances of your app

If you want to prevent a user from running multiple instances of your application on the same computer, you can do so by using a Mutex as shown in the example below.

{% code overflow="wrap" %}

```csharp
[STAThread]
static void Main()
{
    bool bMutexAcquired = false;
    using (Mutex mutex = new Mutex(true, "Unique_Mutex_Name", out bMutexAcquired))
    {
        // If the mutex was not acquired, we should not run the app. 
        if (bMutexAcquired == false)
        {
            return 0;
        }
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
```

{% endcode %}
