Click here to Skip to main content
15,745,509 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

I have a windows service which interaction with database via webservice and create some assignments for employee in background depend on logic written in service.

Suppose once service invoked and created 5 assignments then i want to show notification with icon in system tray telling 5 Assignments created .


Please tell me how can i achieve this?


Many Thanks In advance..


Sachin
Posted

In general, a Windows Service cannot work with UI directly, in particular, it cannot interact with the notification area of the system tray. The reason is apparent: the Windows Service keeps running when the user logs off or nobody is logged on, when the graphical user environment is not available.

The problem is solvable though. You need to write a separate application which should be a windowed interactive application shown in the notification area of the system tray. Your Windows Service should provide communication channels, so your interactive application could connect the service for data exchange and getting notifications.

As both applications are on the same machine, the problem can be solved based on named pipe communication. Your Windows Service can implement named pipe service. For example of such service, please see this code sample:
http://msdn.microsoft.com/en-us/library/aa365603(v=vs.85).aspx[^].

If you need your Windows Service to send event notifications, you probably need more complex schema with two separate channels to provide inversion of control (http://en.wikipedia.org/wiki/Inversion_of_control[^]) and publisher-subscriber service.

Your interactive application can connect to first channel and subscribe for notification; when it is connected, the Windows Service should send notifications to the other channel until your interactive application is disconnected or simply closed. You Service code should be able to handle such non-graceful disconnection by handling exception which should result in discontinued subscription.

I suggest you develop and test this mechanism on prototype using two interactive applications first, before embedding it to your Service. Optionally, you can use TCP sockets to implement the same mechanism if subscription and notification.

—SA
 
Share this answer
 
You Must create an another .exe and run with shell

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="your exe path";
proc.Start();


This is your problem solution.
I am Writing My Assignments on Text File and after run my assignments exe and I can Show Notification.

Windows Service Projects dont allow show & call forms.
This is not Windows service ability.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900