Re: Windows Services GUI
From: Iain Mcleod (mcleodia_at_dcs.gla.ac.uk)
Date: 10/07/04
- Next message: Eric Sabine: "Re: How do I make the enter key act like a button click?"
- Previous message: TerryW: "beginread networkstream"
- In reply to: Christopher Kurtis Koeber: "Re: Windows Services GUI"
- Next in thread: kimpton: "Re: Windows Services GUI"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 7 Oct 2004 22:08:17 +0100
See the thread entitled:
Open a form from a Windows Service
It's very recent and discusses exactly what you are talking about.
I shall paste the reply below:
Regards
Iain
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/default.aspx?pull=/library/en-us/dnhcvs04/html/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" <Rob@discussions.microsoft.com> wrote in message
news:FAD6128A-26B3-403B-8D20-ABCB611253D0@microsoft.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" <Rob@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/>
>>
>>
"Christopher Kurtis Koeber" <c_koeber@myrealbox.com> wrote in message
news:ecEFs8KrEHA.3608@TK2MSFTNGP14.phx.gbl...
> What's so embarrassing about someone asking for help using your name? It
> could be just a coincidence that this person has the same name as you.
>
> Christopher
>
> "kimpton" <kimpton@community.nospam> wrote in message
> news:1AFC4B4E-9970-4850-B964-752211299913@microsoft.com...
>> hey!
>>
>> please don't post embarressing questions with a name the same as mine :)
>>
>> "Kimpton" wrote:
>>
>>> I am trying to write a program with VB.NET to run as a service. I have a
>>> good
>>> grasp of VB.NET but have never made a service before. I am strugling to
>>> get a
>>> GUI interface with a system tray icon working correctly in a service.
>>> Please
>>> help!
>>> Thanks!
>
>
- Next message: Eric Sabine: "Re: How do I make the enter key act like a button click?"
- Previous message: TerryW: "beginread networkstream"
- In reply to: Christopher Kurtis Koeber: "Re: Windows Services GUI"
- Next in thread: kimpton: "Re: Windows Services GUI"
- Messages sorted by: [ date ] [ thread ]