-2

I have created a c# application and need to ensure that if it is run from two separate locations on disk a fresh instance of the program is created.

How might I go about doing this?

Persistence
  • 3,136
  • 3
  • 27
  • 66
Gianni Giordano
  • 144
  • 1
  • 2
  • 13
  • That happens already by default. What exactly is the problem here? – Cody Gray Jan 15 '17 at 19:57
  • Actually, only one istance is being execute, and for me is right. If I want to execute another istance of the same application, from different path, but that have another form title, I don't know how make this – Gianni Giordano Jan 15 '17 at 20:03

1 Answers1

3

If I am understanding correctly, you want to allow multiple instances but have each instance display a different form title. If so, one possible solution would be to use Mutex to check if it is the only running instance. Instead of restricting the additional instances, have it use a new form title, like adding a [2], [3], etc. to the end. Here are some links on how to use Mutex to check if it is the only running instance.

How can I check if my program is already running?

Prevent multiple instances of a given app in .NET?

How can I prevent launching my app multiple times?

Community
  • 1
  • 1
frostbyte
  • 420
  • 5
  • 13
  • Thanks for your reply. I thing that your link are sufficient for my request. – Gianni Giordano Jan 16 '17 at 05:59
  • If you find a question that has already been answered elsewhere on Stack Overflow, you should flag it as a duplicate, instead of posting an answer with links to the other questions. – Cody Gray Jan 16 '17 at 12:05