views:

24

answers:

2

Hi,

i am creating an instance of ServiceController using a remote/local machine name and the name of the service. When I type sth. like stackoverflow.com as machine name the contructor blocks for a long time and returns an exception.

Example:

string MachineName = "stackoverflow.com"
ServiceController("RemoteRegistry", MachineName );

How can I set here a kind of timeout to cancel this process?

+1  A: 

This is subject to the standard TCP/IP connection time-outs. The same ones you see when trying to visit a web site that's off line with your browser. Yes, you can change them by editing the registry. You can make them longer. Not shorter.

Perhaps you can ping it first if this often fails.

Hans Passant
A: 

hmmm

ping will not help me. I think I will put this into a Backgroundworker and cancel the backgroundworker when I want. I think this would help me to destroy the blocking ServiceController ctor.

mrbamboo