• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

C# .NET Windows Service with a form


i wqant to create a windows service that will start up with the pc and the icon sit on the wondows toolbar (like for example the volume control can do)... and then if I detect a errror in its processing I want to make the icon flash ... and then I need to be able to click on the icon and it will bring up a form where I can show details of the error etc.

Could somebody outline the steps in doing this ....

Any help appreciated ...
3 Solutions
The best way is to use two different apps - windows service itself, and a winforms app to sit on the toolbar and listen to windows service.
murfinpAuthor Commented:

how would i listen ..... the service itself needs an event handler that just sits and waits and then processes an event how do i create a console app with an event handler that just sits wand waits for an event to get fired ...

Following up on lazyberezovsky's suggestion, there are several ways you can get the service to communicate with the application that sits on the toolbar.  There are some direct methods, where one application can communicate with another, but I've never looked into that kind of application.  (A quick google search tells me that the magic word for .NET interprocess communication is "remoting," though people also have client/server solutions using "named pipes".)
I would recommend having the service either write windows log messages (a very typical thing for a service to do), or simply write entries in a specific folder.  If you go the log message route, your toolbar application would check for new messages at every n milliseconds, and then change its status (or pop them up).  Similarly, if you write messages to a common folder, your toolbar application would use a FileSystemWatcher to watch for new files (or a modification to a single one, if you prefer).
I would also recommend you make your toolbar application use a NotifyIcon.  These sit (typically) in the rightmost part of the toolbar, like volume and networking and any instant message services you have.  In fact, NotifyIcon makes it trivial to popup a message like the print monitor or your favorite IM service does.  You can do this, and then change your icon to show that there are events waiting for the user to respond.
The biggest issue I perceive would be getting the notify application to start itself.  I don't know how you would get it to pop up automatically for each user.  If the user starts it by themselves, then you're in good shape.
Hope this helps!
Service and it's console can also communicate by WCF.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now