J
John
I have a C# program that relies on a service (let's call it myService.exe).
So I wrote a routine that makes sure the service is running:
int iProcessID = IsProcessRunning("myService.exe");
Process myProcess = Process.GetProcessById(iProcessID);
These commands work great (I can post the IsProcessRunning() code if
necessary, but since that's not the issue I thought I'd leave it out).
Here's where the code fails: I check to make sure the process is alive using
this code
while(!bShutdown)
{
myProcess.WaitForExit(500);
if(myProcess.HasExited)
{
break;
}
else
{
// Periodic functions go here...
}
}
On Windows XP the code works great. On Windows Vista the .HasExited property
causes an Access Denied error. I'm sure it has something to do with
permissions, but I haven't figured it out yet. Can anyone help?
Thanks,
John
So I wrote a routine that makes sure the service is running:
int iProcessID = IsProcessRunning("myService.exe");
Process myProcess = Process.GetProcessById(iProcessID);
These commands work great (I can post the IsProcessRunning() code if
necessary, but since that's not the issue I thought I'd leave it out).
Here's where the code fails: I check to make sure the process is alive using
this code
while(!bShutdown)
{
myProcess.WaitForExit(500);
if(myProcess.HasExited)
{
break;
}
else
{
// Periodic functions go here...
}
}
On Windows XP the code works great. On Windows Vista the .HasExited property
causes an Access Denied error. I'm sure it has something to do with
permissions, but I haven't figured it out yet. Can anyone help?
Thanks,
John