Maui - create only one instance

Dani_S 3,786 Reputation points
2024-03-18T08:35:55.1366667+00:00

Hi,

I have maui app on WINDOWS 8 desktop.

I have shortcut to exe.

When i click on exe it create and instance of this app.

It possible to limit to only one instance of app will be alive ?

Thanks in advance,

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,499 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 42,511 Reputation points Microsoft Vendor
    2024-03-21T05:16:54.2166667+00:00

    Hello,

    After in-depth investigation, activating the existing instance is better than mutex.

    Because when using Mutex, the program will still go through the process of starting and exiting, but using the instantiation feature provided by WinUI, the second program window will not be launched.

    You could refer to Making the app single-instanced for more detailed information. Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


2 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    5 deleted comments

    Comments have been turned off. Learn more

  2. Bruce (SqlWork.com) 65,211 Reputation points
    2024-03-20T15:30:34.99+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.