c# find process by name

C#
if (Process.GetProcessesByName("notepad").Length == 0)
{
    //closed
	return;
} 
else
{
  //process found
}
Source

Also in C#: