Feedback

Prüfen ob ein bestimmter Prozess gerade ausgeführt wird

Sprache: C#

Die Funktion prüft, ob ein bestimmter Prozess gerade ausgeführt wird. Beispielaufruf für den Windows Taschenrechner: CheckIfAProcessIsRunning("calc");
// using System.Diagnostics;

/// <summary>
/// Check if a process is running
/// </summary>
/// <param name="processname">the processname</param>
/// <returns>true if the process runns otherwise false</returns>
private bool CheckIfAProcessIsRunning(string processname)
{
   return Process.GetProcessesByName(processname).Length > 0;            
}
// using System.Diagnostics;

/// <summary>
/// Check if a process is running
/// </summary>
/// <param name="processname">the processname</param>
/// <returns>true if the process runns otherwise false</returns>
private bool CheckIfAProcessIsRunning(string processname)
{
   return Process.GetProcessesByName(processname).Length > 0;            
}