Only one app running at a time

  • Thread starter Thread starter Tom Garik
  • Start date Start date
T

Tom Garik

Hi,

Anyone knows the answer to this one: I have .NET application that I want to
allow at most one to be running at any given time. If one is already running
bring it to the front if someone tries to run it again. This seems pretty
standard in Win32 but I just wonder if there is .NET way to do the same
without pinvoke. Appreciate it. Thanks.

Tom
 
Tom Garik said:
Anyone knows the answer to this one: I have .NET application that I want to
allow at most one to be running at any given time. If one is already running
bring it to the front if someone tries to run it again. This seems pretty
standard in Win32 but I just wonder if there is .NET way to do the same
without pinvoke. Appreciate it. Thanks.

Code for detecting the other instance:

<http://www.google.de/[email protected]>
 
i have seen Herfried's detection routines and am using one almost verbatim
in my app. (it works good - thanks Herfried!) But, i would still like to
know what the process is to activate an existing instance once it is
detected. if you learn anything on this, Tom, please post back!

thanks! =)
 
Thanks Herfried and all. As for bringing existing instance to the front I
think you might be able to use
Control.FromHandle(process.MainWindowHandle).BringToFront() after getting
the process using PrevInstance(). Haven't tried it yet but it should work.
 
i will check it out, thanks! =)

Tom Garik said:
Thanks Herfried and all. As for bringing existing instance to the front I
think you might be able to use
Control.FromHandle(process.MainWindowHandle).BringToFront() after getting
the process using PrevInstance(). Haven't tried it yet but it should work.
 
Back
Top