I have a simple snippet of code that loops through a process() and writes to
the eventlog the contents of the Responding property. I have run this in a
console app and it returns False as it should. I have moved this code to a
windows service but it will always return true. The code is:

Dim proc() As Process = Process.GetProcessesByName(_processToMonitor)
Dim p As Process
For Each p In proc
EventLog.WriteEntry(p.ProcessName & _
" id: " & p.Id & _
" full path: " & p.Modules(0).FileName & _
" responding?:" & p.Responding.ToString)
Next

I have tried to change the Account used for the service but always get the
same results (True). I have moved this code to an .exe but I am curious to
why it runs differently in a windows service.

Regards,
David

P.S. If someone wants to test this I have found the easiest why to get an
application to a Not Responding status is to open a large file with notepad.

Re: windows service and the Responding property of a Process by Willy

Willy
Wed Apr 20 12:52:24 CDT 2005


"harumscarum" <hello@ABC.COM> wrote in message
news:9DF53CC8-A009-4C68-9D4F-2F4D40297D57@microsoft.com...
>I have a simple snippet of code that loops through a process() and writes
>to
> the eventlog the contents of the Responding property. I have run this in a
> console app and it returns False as it should. I have moved this code to a
> windows service but it will always return true. The code is:
>
> Dim proc() As Process =
> Process.GetProcessesByName(_processToMonitor)
> Dim p As Process
> For Each p In proc
> EventLog.WriteEntry(p.ProcessName & _
> " id: " & p.Id & _
> " full path: " & p.Modules(0).FileName & _
> " responding?:" & p.Responding.ToString)
> Next
>
> I have tried to change the Account used for the service but always get the
> same results (True). I have moved this code to an .exe but I am curious to
> why it runs differently in a windows service.
>
> Regards,
> David
>
> P.S. If someone wants to test this I have found the easiest why to get an
> application to a Not Responding status is to open a large file with
> notepad.
>

This is because Windows services run in a sandboxed desktop/windowstation,
that means it has no access to the interactive desktop/windowsstation.

To run your service in the interactive desktop, you have to enable the
"Interact with desktop" attribute for your service, but this is not a good
idea and should only be done when debugging.

Willy.