Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi i created a window service to check if my windows application is closed or open, my problem is how can i check if the application is already open or close the execute my code to open it again, i created this because someone is always closing my application it's not for an malicious intent.

What I have tried:

i already have a code for opening my application that i created using window service.
Posted
Updated 23-Jun-20 1:30am
Comments
F-ES Sitecore 23-Jun-20 7:32am    
You not having malicious intent doesn't make it magically possible. Services don't really have access to the interactive user, if it started an app the user wouldn't see it as it is running in a different user session.

1 solution

If you're talking about service & application 'on a single, local pc', then, if the application creates a unique mutex, the service can check if the mutex is already in use or not... already in-use means the application is running. When the application ends, by fair means or foul, it closes and disposes of the mutex ...

That is but one way - do a google search for C# Single Instance Application and you'll likely come up with some code - this for example Single instance C# application · GitHub[^]
 
Share this answer
 
v3
Comments
Maciej Los 23-Jun-20 8:33am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900