WPF On Start determines if a process is running and brings the application to the forefront

I have a pretty simple problem.

When the program is started and the user tries to start another instance. This new instance should lead the old instance to the beginning and exit.

The solution to the seams is quite simple, I could take the code http://www.codeproject.com/KB/cs/oneprocessonly.aspx and do with it.

Luckily / Sorry, I'm using WPF. This means that I am unable to control the content of the Main () method.

I found a solution to this problem "How can I provide my own Main () method in my WPF application?" @ http://learnwpf.com/Posts/Post.aspx?postId=a5643949-ab80-47f9-93c8-f5e8e5782d34 .

But this solution leads to other problems, such as Expression Blend stats, in the absence of the App.xaml file.

I could use the OnStarted App classes, but I am using the Split WPF splash screen resource, this will mean that an additional splash screen will be displayed.

My last concern with this method is that it cannot be “promising” for me: (.

Is there any WPF style solution for this problem?

Thanks in advance.

+3
source share
1 answer

I believe this link may help you: A single-instance C # application

, , . - PostMessage.

Main(), , Expression Blend , App.xaml . Expression Blend Windows, ( App.cs).

Expression Blend, , , . , , Visual Studio XAML , . ( ?) Expression Blend .

+6

Source: https://habr.com/ru/post/1709783/


All Articles