Hi,
I have a piece of code that makes remote calls to another host to retrieve the status of a number of windows services. Each remote server status check is done with a new ServiceController object on a separate thread, and each of which takes approx 20
seconds. For example:
Parallel.ForEach(serviceMap, service =>
{
ServiceController serviceController = new ServiceController(service.Name, service.Host);
Trace.TraceInformation("Calling service controller '{0}' on thread id '{1}'.", service.Name, Thread.CurrentThread.ManagedThreadId);
Stopwatch sw = new Stopwatch();
sw.Start();
var responseStatus = serviceController.Status.ToString();
sw.Stop();
Trace.TraceInformation("Service controller '{0}' status on thread id '{1}' took '{2}' seconds.", service.Name, Thread.CurrentThread.ManagedThreadId, sw.Elapsed.Seconds);
});
The serviceController.Status is invoked on different worker threads but appear to block; perhaps deeper in the win32 library where ServiceController wraps the advapi32.dll.OpenService function or maybe at the transport/port level? I was under the impression
different dynamic ports will be allocated
for each of these calls. Calls are made to the same host (perhaps hitting the bottleneck on the target host side?). Any idea why the ServiceController RPC calls to the other host appear to be are processed synchronously?
Txs
B.