title: .NET - limiting the number of instances of an execution unit
body: <p>Let's say I have an application written in C# called EquipCtrl.exe which runs as a local process on a PC to control a piece of equipment.</p>
  
  <p>Obviously, I would wish to have only one instance of Equipctrl to run on each PC. If I had two equip to control per PC, I would then limit it to two instances per PC.</p>
  
  <p>The way I did is was either one of 
  1. Process name. I name the process EqCtrl and at process start-up, it would count the number processes with the name "EqCtrl".
  2. Execution name. At start-up count the number of processes with the execution name EquipCtrl.exe.
  3. Registry record.
  4. SQL Server database record.</p>
  
  <p>To me, process name or execution name detection is the simplest and what I do most (if not all) of the time. But, they are susceptible to name clashing. Even if I go further to find out the execution path, the limit could be circumvented by copying the execution file to another folder.</p>
  
  <p>What is the best way to perform execution limiting on .NET? Why? Is registry record the best way?</p>