detect 2nd instance

  • Thread starter Thread starter Doug Bell
  • Start date Start date
D

Doug Bell

Hi
can anyone point me in the right direction of detecting if an application is
running so that if a 2nd instance is started it can check and self
terminate?

Thanks

Doug
 
Hi Doug,

If Process.GetProcessesByName
(Process.GetCurrentProcess.ProcessName).Length > 1 Then
MessageBox.Show("Another Instance of this process is already running")
Application.Exit()
End If

Vijrag.
 
Doug said:
Hi
can anyone point me in the right direction of detecting if an
application is running so that if a 2nd instance is started it can
check and self terminate?

There's a nice solution for this in Chris Sells' book Windows Form
Porgramming in {C#|VN.NET}. You can get the code from his web site at
http://www.sellsbrothers.com/writing/wfbook/.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top