0

I have an app in Windows Forms, written in C# (.Net 4.7.2) that, when minimized, goes to the system tray. The requirement is that when the user clicks on the desktop shortcut again, if the application is already running hidden in the tray, the screen should be restored instead of opening a new instance of the same application. I know that this behavior is common in several applications, but I still haven't found a way to do this in Windows Forms. Thanks in advance!

Ronye Lago
  • 122
  • 2
  • 7
  • Use Mutex. There are many examples. – Alexander Petrov Mar 09 '21 at 13:23
  • Sounds very much like [this posted problem](https://stackoverflow.com/questions/50552592/run-the-current-application-as-single-instance-and-show-the-previous-instance) – Mong Zhu Mar 09 '21 at 13:24
  • so, do you think you can solve your problem with Jimis answer? then I would close this question as a duplicate – Mong Zhu Mar 09 '21 at 13:30
  • I tried to implement the solution proposed by Jimis, however, when the application is already running and both open again nothing happens ... – Ronye Lago Mar 09 '21 at 14:26
  • This is built into VB.Net, which you can use from C#. See [here](https://www.codeproject.com/Articles/12890/Single-Instance-C-Application-for-NET-2-0) for an example... – Idle_Mind Mar 09 '21 at 16:07
  • Have you read this: [Single Instance Winforms application](http://www.hanselman.com/blog/the-weekly-source-code-31-single-instance-winforms-and-microsoftvisualbasicdll) – Harald Coppoolse Mar 10 '21 at 09:57

0 Answers0