Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to best expose methods in WinForm?

I have a C# form application that connects to a electronic device using the serial port. The class "'SerialCommunicationManager'" hooks up to the serial port on application startup and handles the dirty business of talkning to the device.

What I would like is to expose the following methods.

  • Write()
  • SerialDataReceived event
  • SerialDataTransmitted event

Primarily a local website running on the same machine is the one I want to expose the methods for, but in the future I imagine the need for external applications as well.

What is the easiest way to expose the functionality?

  • TCPIP client server?
  • Web service? (Can I create a web service inside a WinForm?)
  • other?

Big thanks

//David

enter image description here

like image 797
David Avatar asked Sep 04 '11 07:09

David


1 Answers

I would recommend self-hosting a WCF Service. This provides you a huge amount of flexibility in terms of how you serve and expose this information, including being able to change the method by which its served via configuration.

like image 99
Reed Copsey Avatar answered Sep 23 '22 09:09

Reed Copsey