473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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

Nov 21 '05 #1
2 5860
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)

Nov 21 '05 #2
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gerhard Swart | last post by:
Hi all. I'm writing a queue browser that reads queues from a specified machine and then display the data that's on the queue. I am using the MessageQueue Class in .Net(C#). I get the problem...
0
by: Anthony Boudouvas | last post by:
Hi to all, i have made a module that can get a list of services running on a local or remote machine. So i have machine A that get a list of services of machine B The way the configuration is...
1
by: Tom J | last post by:
What do I have to do to get System.ServiceProcess.ServiceController.ExecuteCommand(int) to work? I have written a service that overrides OnCustomCommand to handle commands sent to it. If I...
16
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the...
0
by: Scupper | last post by:
I'm trying to write an application that will periodically check a server for certain services and, if they are not running, attempt to start them. I'm using System.ServiceProcess and have no...
1
by: SenthilVel | last post by:
Hi We use System.ServiceProcess.ServiceController class is used to get the list of windows services installed in a particular machine. Also we use...
1
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I am using a ServiceController to start and stop my service. If i use the service localy and use the service controller it works fine. If i install the service on my server and try to...
7
by: =?Utf-8?B?YXVsZGg=?= | last post by:
hello, i'm try to research the way to open a remote machine's to collect the services and processes. i have the local data collection running but i can not figure out what MSDN or the C# help file...
3
by: MedIt | last post by:
Hi all, I am trying to controll a service programatically using the ServiceController class .net c#. It is giving me an error that it cannot find the service name. I have tried it stopping...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.