Most likely, this code is designed to keep number of instances 0 to 1; more exactly, second instance of loading runs for a short time until it discovers that the first instance is already running, to terminate immediately. If you remove this code, you will be able load your application any number of times, but you cannot make this number, say, 3 or 4 and no more. Without looking at the code, it's hard to say how to modify it; and most likely it would not make any sense.
What happens with you is the usual consequence of using some other person's code without understanding how it works. And then you try to modify behavior using trial-end-error, blind-folded approach. This is not how such things can be achieved.
Most likely, you will need to write a brand new code to achieve what you want. But first think if you really need it and why. There is a number of ways to limit number of application instances during run time. One simple approach is this: in your application, run
System.Diagnostics.Process.GetProcessesByName(string)
using the name of current process. Some of such processes can have the same name by coincidence, so examine
Process.MainModule
for each process and
System.Diagnostics.ProcessModule.FileName
to make sure it is loaded from the same executable file, in your case, same as main executable module of your entry assembly.
Based on this information, calculate the total number of processes running a separate instance of your application and decide if you want to run another one. If not, terminate your current process immediately.
See:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.aspx[
^].
—SA