Friday, September 21, 2012 1:50 PM
I'm developing an app that needs to run in the background and run at all times. ("Engine"). So far, Engine was created as a Windows Service app. I have also created a second WinForm app ("Monitor") to control and monitor this service. Monitor will start automatically but be minimized to the system tray. Notify Icon will display current status. User can right click icon to start/stop Engine or double click to show Monitor. Subsequently, when Monitor is "minimized", it collapses back to system tray.
When Monitor is displayed, I want it to display running activites... (similar to what I would see during a complete backup like the files being copied, progress meter etc...). I know that a service exposes certain properties like Status (Running, Starting, Stopping) , but I want to display my own info.
My question is... How do I code this in the service and winform app to be able to intercept such a stream of information. Can I bind or display info from an event log? Create an Event and Handler?
I really only want to capture what is happening while form is visible and don't want to save all the details. I will save more general info in event log like Starts / Stops / Results.
A quick code sample in either VB or C# for Service / Handler would be great or just describe library / technique to use.
Friday, September 21, 2012 7:18 PM
You can host a WCF Service in your Windows Service. WCF Service will have functions which you can call from Windows Form to show activity details. Following link should help you with steps to host WCF Service in Windows Service
Else you can use Sockets (TCP or UDP) to communicate between Windows Service and Window Applications.
Gaurav Khanna | Microsoft VB.NET MVP
Monday, September 24, 2012 8:02 AMModerator
In addition to Khanna' suggestion, below are some other Interprocess Communications(IPC) mechanisms are supported by Windows.
Microsoft All-In-One provide some samples about IPC.
Bob Wu [MSFT]
MSDN Community Support | Feedback to us