Christoph,
The easiest way to have a service accept a "command" to do something is to
override the ServiceBase.OnCustomCommand method and have it call the same
procedure your Timer.Elapsed event handler calls.
Then you can use ServiceController.ExecuteCommand to invoke this custom
command.
Note I would probably define an Enum of CustomCommands that my service
supported so its easier to keep track of them. A custom command for
OnCustomCommand is an integer between 128 & 256, which also means you can
have multiple custom commands defined.
Remember that ServiceController can control services on your local machine
as well as services on remote machines. Note you may need to configure the
various machines to allow remote control of services.
An alternative, more flexible method, which also entails more work, is to
enable your service for .NET Remoting. You could either make it a .NET
Remoting Server, in which case you call a method to have it perform some
action, or a .NET Remoting Client, and possible handle an "update data
event" on your server remoting object that says to update data...
Both of the custom commands & remoting with a service are discussed in
Matthew MacDonalds book "Microsoft Visual Basic .NET Programmer's Cookbook"
from MS Press.
Hope this helps
Jay
"Christoph Duesmann" <c.********@web.de> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
Hi !
I wan't to code a service which will be installed on some clients in our
network.
The service should have the following features :
- Scan all properties of the Client (Hardware, Software etc)
- Create a log (eg. logfile.txt)
- Optional : Insert the data directly in an SQL-Database
- All these functions should occur, when a Timer elapsed or when I send a
command to do this.
My problem : Up to the manual command all functions have been
implemented. So, my question is : How can i communicate with these services to do
things when i want them to do ?
For better understanding : The service has started succesfully and is now
waiting for commands like "Start Scan"
Thanks !!!!!
Christoph