Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

ServiceContoller is sequential in its RPC calls from a multi-threaded client

$
0
0

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.





Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>