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.

4
  • Why cant you use websocket or similar thing? You can check this question's program for inspiration. stackoverflow.com/questions/42680413/… Commented Mar 20, 2019 at 21:08
  • Why throw regular Python into this Mix? I would stick with IronPython - stackoverflow.com/questions/7053172/… Commented Mar 20, 2019 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. Commented Mar 20, 2019 at 21:46
  • Please consider providing a concrete example, not pseudo-code. Commented Mar 20, 2019 at 22:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.