ServiceProcess.ServiceController.Start on remote machine - why synchronous?

V

Vadim Rapp

Hello,

I have the following code:

==========
Dim RemoteService As System.ServiceProcess.ServiceController
RemoteService = New System.ServiceProcess.ServiceController("service1",
txtMachine.Text)
remoteservice.start
==========

If txtMachine is my local machine, remoteservice.start returns immediately,
as it should.

But if it's remote machine, it returns only when the service there enters
"Running" state.

Is this a bug or feature?


thanks,
Vadim Rapp
 
C

Chris Dunaway

I don't know if it's a bug or not but you can call it asynchonously
like this (check for typos):

'make a delegate to call our start sub
Private Delegate Sub StartDelegate()

'Elsewhere
Dim s As New System.ServiceProcess.ServiceController
Dim sd As New StartDelegate(AddressOf s.Start)
Dim AsyncResult As IAsyncResult
AsyncResult = sd.BeginInvoke(Nothing, Nothing)

'Code should return immediately
'Execute other code here if needed.

'To wait for the delegate to finish. This is not technically
needed if
'the method being called does not return a value, except maybe
for
'exception handling.

sd.EndInvoke(AsyncResult)
 
V

Vadim Rapp

Hello Chris,
You wrote in conference microsoft.public.dotnet.languages.vb on 5 Jul 2005
12:26:10 -0700:

CD> I don't know if it's a bug or not but you can call it asynchonously
CD> like this (check for typos):

CD> 'make a delegate to call our start sub
CD> Private Delegate Sub StartDelegate()

CD> 'Elsewhere
CD> Dim s As New System.ServiceProcess.ServiceController
CD> Dim sd As New StartDelegate(AddressOf s.Start)
CD> Dim AsyncResult As IAsyncResult
CD> AsyncResult = sd.BeginInvoke(Nothing, Nothing)

thanks, that worked!

Vadim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top