How to display progress in a WinForm app for a running Service.
-
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.
Ed
All Replies
-
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
http://msdn.microsoft.com/en-us/library/ms733069.aspx
Else you can use Sockets (TCP or UDP) to communicate between Windows Service and Window Applications.
Gaurav Khanna | Microsoft VB.NET MVP
- Proposed As Answer by Bob Wu-MTMicrosoft Contingent Staff, Moderator Monday, September 24, 2012 7:57 AM
- Marked As Answer by Fast_EddieD Tuesday, September 25, 2012 10:01 PM
-
Monday, September 24, 2012 8:02 AMModerator
In addition to Khanna' suggestion, below are some other Interprocess Communications(IPC) mechanisms are supported by Windows.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx
Microsoft All-In-One provide some samples about IPC.
http://1code.codeplex.com/wikipage?title=IRPC#
Best Regards,Bob Wu [MSFT]
MSDN Community Support | Feedback to us


