2

So I want to have two applications: The first one will be a WinForms GUI (probably .NET Framework) and the second one is a .NET Core console application that does all the processing.

My goal is to have the WinForms applications start the console application when needed and provide the task, which the console application should complete, as a startup parameter. The console application should then work on the task and report the current status/progress back to the GUI every second or so including errors and warnings. When everything is done the console application should report that it has finished and close.

I thought I could start the console application using a ProcessStartInfo that would redirect the output of the console application. The console application would just output all important data each second and the WinForms application would then filter and process this output to get the data.

This looks like a not very optimal way to me and I hope I can get some feedback on what I could try/should use instead of this solution. I am very new to communication between two applications.

Lukas
  • 169
  • 1
  • 2
  • 8
  • 1
    This is offtopic, but if you insist - try to google "C# inter process communications" – vasily.sib Jun 10 '19 at 09:00
  • 1
    There acronym you are looking for is called IPC, and there are oodles of ways, however if you are worried about the right and wrong way to do things, this whole design seems iffy, why not just make a service like wcf, web api – TheGeneral Jun 10 '19 at 09:00

1 Answers1

1
  1. I've never done what you are attempting to do but i would look in to C# Socket programing this way you can establish communication between two apps that can send data fluently in between but it will require a Server / Client setup, the good news is that you should be able to start the server by starting the process and then establishing a connection.

https://learn.microsoft.com/en-us/dotnet/framework/network-programming/socket-code-examples

  1. Create a service that runs in the background utilizing either SOAP or Socket https://www.guru99.com/soap-simple-object-access-protocol.html

  2. ASP.NET MVC API (Least Preferable) but it will support many other project and can run on HTTP

I'm not sure if this solves your problem immediately but I hope it can help you to find the answer that you seek. Something i would recommend is that you

  • Why would a REST API be less preferable than SOAP, let alone inventing your own protocol over sockets? – CodeCaster Jun 10 '19 at 10:19
  • For my understanding he is looking for a way to communicate with an app/console something local, this leads to a REST API being over kills since more resources will be needed IIS Server DNS server if he dont plan to go to each device and edit the host file etc. But ofc if the case would be to serve a network then REST API is optimal I just mentioned that it was not optimal based on the post requirement. – Nasar Eddaoui Jun 10 '19 at 15:31
  • And as you see in his requirements he wishes to get a steam of responses with what is going on this is far more complicated with a RESTFUL API that only returns a single response. Socket can establish a connection and then reply a stream of data and SOAP can also if do such a thing since I have a little bit of ONVIF Protocol used in CCTV Cameras most of the commands are executed trough SOAP – Nasar Eddaoui Jun 10 '19 at 15:39