0

I am curious as to the best way to share data from a WPF program with a python script from within a loop where the values are continuously being updated. Here is a psuedo-codish example that expresses the kind of functionality I'm hoping for.

Wpf example:

    while(true)
{
var x = arbitraryNumber0;
var y = arbitraryNumber1;
var z = arbitraryNumber2;

sendToPython(arbitraryNumber0, arbitraryNumber1, arbitraryNumber2);

arbitraryNumber0++;
arbitraryNumber1++;
arbitraryNumber2++;
}

Python script example:

  #stream in x, y, z From WPF 
  product = arbNumFromWPF0 * arbNumFromWPF1 * arbNumFromWPF2
  #do stuff with product

I have tried using c# process's but the problem was that it would need to start the python shell on every new iteration. Which would cause my system to crash. I have looked into ironpython, pipes, and sockets but can not find an example similar to what I'm trying to do, and am wondering what method I should use to achieve this functionality. Any help would be greatly appreciated.

Ben Jenney
  • 75
  • 6
  • Why cant you use websocket or similar thing? You can check this question's program for inspiration. https://stackoverflow.com/questions/42680413/connecting-python-socketserver-with-c-sharp-client – Manoj Choudhari Mar 20 '19 at 21:08
  • Why throw regular Python into this Mix? I would stick with IronPython - https://stackoverflow.com/questions/7053172/how-can-i-call-ironpython-code-from-a-c-sharp-app – Leonid Mar 20 '19 at 21:17
  • I see that IronPython seems to allow for the writing of python inside of .net, and that it can execute python scripts, I just can't find an example that seems to show how to update parameters as they are being read by a separate python script and that could keep reading those updated values on each new iteration. Would I have to execute the script every iteration? I've been having a hard time finding a good resource I could use to figure out IronPython's functionality. – Ben Jenney Mar 20 '19 at 21:46
  • Please consider providing a concrete example, not pseudo-code. – dymanoid Mar 20 '19 at 22:33

0 Answers0