none
How to communicate from a Windows service to a Windows store App via any Events raised from Windows service? RRS feed

  • Question

  • Hi,

    I have a windows service in which i have code for connecting to a Printer.The code for Printer communication is in the printer software provided dll. As i am unable to add this .NETFramework dll in Windows store app, i added code for printer communication in Windows service and in Windows store app i trigger the printer connection via Windows service.

    Now I want to do a receipt print automatically from Windows store app when a printer is connected. I added the printer connected status event in Windows service. But i need to transfer this Printer connected event to Windows store app now.

    How to raise any event from Windows service which talks to Windows store app? or how to communicate from Windows service to Windows store app?

    Kindly help on this.

    Thanks.

    Wednesday, September 4, 2019 1:47 PM

All replies

  • Services don't raise events. I don't know that I fully understand your problem but I really question why you're using a windows service. Do you need this for some other functionality in your app? If not then I don't believe a service is the way to go.

    It really depends upon your architecture but in most cases if you need functionality outside an app then use a REST API or perhaps a WCF service (if you aren't concerned about .NET Core). In both cases it is like calling a third party library except it is external to your app and everybody supports it across platforms and most languages. Your app is then responsible for calling the API when you need to do something.

    On the eventing side it is harder though as neither APIs nor services tend to go this route. If you need a lot of eventing then WCF does support bidirectional communication which would allow you to do notifications from the service. Alternatively just polling periodically from your app seems more than sufficient. Perhaps every 30 seconds your app calls the API to get the current printer(s) available. This puts the oneous on the app to decide when to update and doesn't require any sort of event handshaking.



    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, September 4, 2019 5:51 PM
    Moderator
  • Hi CoolDadTx,

    Thank you for the quick response. I will try the idea given above and come back if any.

    Thursday, September 5, 2019 4:33 AM