Rob,
SQL Server has a number of Windows Services (I see at least 3) that run,
plus it has a UI program that runs, the services are listed under Services
in the "Control Panel - Administrative Tools"
The UI program (for SQL Server) is called "Service Manager" is under
Programs - Startup.
The easiest way to have a service accept a "command" (from its UI) is 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.
You can also use WMI (Windows Management
Instrumentation) via the classes in the System.Management namespace to
monitor your windows service.
Here is a recent MSDN article on WMI & .NET:
http://msdn.microsoft.com/vstudio/de...ml/vs04d6a.asp
In addition to/instead of WMI you can also simply use Performance Counters &
Event Logs to keep track of your service doing work. See
System.Diagnostics.EventLog & System.Diagnostics.PerformanceCounter.
Hope this helps
Jay
"Rob" <Ro*@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Thank you for your information. This is a new area for me.
But I am curious as to how applications such as SQL Server, MSN Messenger,
etc. use the Notify Icons. When the service starts is there a program
whose
UI is hidden? I need to have some form of UI for a service I am
constructing
and I am looking for the best way to go about it.
"Herfried K. Wagner [MVP]" wrote:
"Rob" <Ro*@discussions.microsoft.com> schrieb: > Can a form be opened from a Windows service?
Typically services do not have a UI. If they do, that's a separate
application that communicates with the service over remoting, sockets,
etc.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>