Duplicate process check

If you are creating your own integration module for CRM, then it is very wise to make sure that the process is running only once. For performance reasons you can decide to split the process in multiple threads, but running a single process multiple times can cause quite some unforseen issues.

The following code snippet will allow you to check if an application with the same name is running already.

string TargetName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
System.Diagnostics.Process[] MatchingNames = System.Diagnostics.Process.GetProcessesByName(TargetName);

if (MatchingNames.Length > 1)
//do something for multiple processes
//do the regular thing for single process

1 comment:

Anonymous said...


Question did you put that code under ISV folder ? cause I recieved a weird message and can not generate a pdf report, however if same code is put on another web directory outside crm it works perfectly