Glenn,
| Is it possible to pass arguements to a .net service once it is in a
| running state.
In addition to the other comments.
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.
As an alternative, depending on the nature of the arguments, I have written
them to the Service's app.config file, then stopped & restarted the service.
If your service only has a single service in it, stopping it causes it to be
unloaded from memory, restarting it should then cause it to re-read its
app.config. Of course if your service reads its config from the registry or
a different file, then you may not need to stop & restart it.
Hope this helps
Jay
| Hello
|
| Is it possible to pass arguements to a .net service once it is in a
| running state.
|
| If this is not possible , are they alternative ways in which to achive
| the same thing?
|
| Glenn
|