# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.soraco.co/docs/faq/how-to-prevent-a-user-from-running-multiple-instances-of-your-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
