如何使用c#.net检查运行特定脚本的php进程是否正在运行

I have a .net application that can execute a php script..

    private const string PROGRAM_CALL = @"php.exe";
    private const string PROGRAM_PARAMETERS = @"scriptA.php scriptA.cnf";     

The following code is executed in the constructor of a class:

ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(PROGRAM_CALL)
            {
                UseShellExecute = false,
                WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                RedirectStandardOutput = true,
                Arguments = PROGRAM_PARAMETERS
            };
            _process.EnableRaisingEvents = true;
            _process.Exited += new EventHandler(Process_Exited);
            _process.StartInfo = myProcessStartInfo;

Then as required the process is started. It can be started by different calls.. Currently this start statement is in a method that is called from numerous places.

 _process.Start();

What I'd like to figure out is if the php script is already running?

What I've tried so far is:

bool isRunning = Process.GetProcessesByName(_process.ProcessName).Length > 0;

However on debug I can see that _process.ProcessName throws an exception (InvalidOperationException)

Kind Regards, Fiona

Set a variable (e.g. a boolean) before starting the process and unset it when the process exits.