What is the best way to open methods in WinForm?

I have a C # form application that connects to an electronic device using a serial port. The "SerialCommunicationManager" class connects to the serial port when the application starts and processes dirty work while talking to the device.

I would like to expose the following methods.

  • Write ()
  • SerialDataReceived event
  • SerialDataTransmitted Event

First of all, the local website running on the same computer is the one I want to disclose for these methods, but in the future I also assume the need for external applications.

What is the easiest way to discover functionality?

  • TCPIP Client Server
  • Web service? (Can I create a web service inside WinForm?)
  • other?

Many thanks

//David

enter image description here

+6
source share
3 answers

I would recommend hosting the WCF service yourself . This gives you tremendous flexibility regarding how you service and disclose this information, including the ability to change the way it is served through configuration.

+4
source

It seems to me that if you want to do it right, you should break the forms application and create:

  • a service that processes a sequential call and has an API that is open via remote access
  • API Forms Application and Service Usage Method

Then, depending on the location of your website, if it remains local (or local local):

  • website must use remote access to call service

else if you plan to have multiple websites:

  • a web service hosted within IIS that will migrate the remote API
  • website that will use the web service

However, if this is too much work, just use remote access and post the necessary methods to the website.

+1
source

In a recent project, we did the following:

  • Record a console application (or Windows service, depending on your needs) that communicates with the electronic device.
  • Make the application host the .NET.NET WCF console.
  • Write a .NET 2 Windows Forms application to communicate through a web service with a console application.

In this context, I could imagine that the website you mention also uses web services (WSDL) to communicate with the console application.

+1
source

Source: https://habr.com/ru/post/896576/


All Articles