Windows Services GUI

Windows Services GUI

Post by S2ltcHRvb » Tue, 21 Sep 2004 23:39:09


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!
 
 
 

Windows Services GUI

Post by Tom Shelto » Wed, 22 Sep 2004 14:28:45


Services are not supposed to have GUI's. It is possible to do it - but is
not good practice. What you would normally do is create the service and
the GUI as separate programs that talk to each other via some form of IPC
(interprocess communication). Since your using .NET, remoting would be one
possibility - it all depends on the level of interaction you require.

--
Tom Shelton [MVP]

 
 
 

Windows Services GUI

Post by Lucas Ta » Wed, 22 Sep 2004 14:36:53

"=?Utf-8?B?S2ltcHRvbg==?=" < XXXX@XXXXX.COM > wrote in



It's bad practice to include a GUI with the service.

Instead, you should create two applications - 1 service, 1 windows form.
The two applications will communicate with each other via Remoting.

--
Lucas Tam ( XXXX@XXXXX.COM )
Please delete "REMOVE" from the e-mail address when replying.
http://www.yqcomputer.com/
 
 
 

Windows Services GUI

Post by a2ltcHRvb » Fri, 08 Oct 2004 21:31:04

hey!

please don't post embarressing questions with a name the same as mine :)
 
 
 

Windows Services GUI

Post by Christophe » Sat, 09 Oct 2004 05:49:38

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
 
 
 

Windows Services GUI

Post by Iain Mcleo » Sat, 09 Oct 2004 06:08:17

ee 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" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...



"Christopher Kurtis Koeber" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

Windows Services GUI

Post by a2ltcHRvb » Sun, 10 Oct 2004 21:07:02

stupid choice words...thanks for pulling me up

apologies other kimpton