473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Open a form from a Windows Service

Rob
Can a form be opened from a Windows service? I have a windows service that I
would like to open a form from a notify icon. I cannot get the Notify Icon
to display nor can I open a form.

Any help would be greatly appreciated.

Rob
Nov 21 '05 #1
3 4456
"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/>

Nov 21 '05 #2
Rob
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/>

Nov 21 '05 #3
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/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rob Wahmann | last post by:
I'm having trouble with the following code appending the form name and an empty value to the end of the url. Can anyone tell me what's wrong? I appreciate any tips or advice you can pass along! ...
4
by: Ricardo Correia | last post by:
Hello, Does anyone know how to open an application from a windows service?? For example, I have a windows service running and using a timer or something else I want to open Windows Calculator!...
2
by: Alexander Feygin | last post by:
I am monitoring certain events with a windows service (derived from System.ServiceProcess.ServiceBase). When a significant event comes up, I'd like to notify the user with a pop-up dialog box or...
2
by: WJ | last post by:
My system is an XP Pro. with the lattest patches & Service pack applied. 1. I have IIS installed with XP first. 2. I have .NetFW 1.1 installed next via Windows Update. 3. I have VS.Net 2003 EA...
3
by: Stephen | last post by:
I'm experiencing a strange problem that has me baffled. I created a webservice with a webmethod that connects to a remote MS SQL Server. It works fine when connecting to one server (running SQL...
6
by: Dean R. Henderson | last post by:
I have a DTS Package I am able to execute successfully from a Windows Form application, but I cannot get this to work from an ASP.NET Web Service, although the Web Service impersonates the same...
3
by: =?Utf-8?B?Zmh1bnRlcg==?= | last post by:
I have a Windows Service that should pop a windows form right before logoff, for the user to enter some information. I got things working fairly well except that the user does not get to see the...
22
by: robertgregson | last post by:
Using C#, .NET3.5, Visual Studio 2008 and WCF on Windows VISTA SP1, I have written a service, service host (as a C# console application) and a client. The service uses...
5
by: Stefano Tonello | last post by:
Hi all, I need to call windows' "open with" dialog from my C# windows form application. After the user selects application, control must return to me (I have to launch directly the process). I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.