I have one application in the WPF that's by default running in the system tray.
I have one scenario in which the user can be confused.
- The application is running in the system tray
- Now, User tries to open the same application by searching the application name in the windows progeam search.
- In this case, The user will not get any acknowledge.
This is my code of Global.cs file. This code having condition for the application if its already running in the system tray or not .
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid))
{
if (!mutex.WaitOne(0, false))
{
return;
}
}
Now, What I want to do is, I want to open the application in the window mode when the user is casing above scenario. I have tried the below code which opens the window of the app, But, The system tray is now having two icons of the same application.
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid))
{
if (!mutex.WaitOne(0, false))
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
}
}
Guide me the ways to open the application in the window mode if there is already instance in the system tray. Or help me to remove duplicate icons/instance from the system tray.