Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,


I am running an exe(SBM Mail.exe which is C# windows apps). But at the same time before Form Load event i want to check whether SBM Mail.exe is been already running or not. If running and it is active means it should not allow another process of same name(i.e.,SBM Mail.exe).

Also i want to check currently running active processes.

Kindly please help me to solve this.
Posted

You can get a process using GetProcessByName[^]. But I am pretty sure that it is not wise to handle such tasks on form level. Because you will probably have many concurrent users of your application it is more likely that you need to handle this on application level. It is an other design issue that you use on server side a regular application as background worker, and not a service - and the problem is not that you use it, the problem is how you need to handle it.
 
Share this answer
 
Why did you tag your question "ASP.NET"? That's confusing.
System.Diagnostics.Process.GetProcessesByName returns a list of processes with a given name.
But your question might also allow for a different interpretation: i.e. the "Form Load" event you mention happens in that "SMB Mail.exe". In that case, the ApplicationFramework is your friend: it makes sure that only one instance is running at a time; and it can forward command line parameters from a later call to the executable to the already running process.
 
Share this answer
 
In visual studio, just make it as a single instance application in project properties. you dont have to check for any other instance being running at all...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900