Click here to Skip to main content
16,004,406 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all,
I have created an application whos tasks are,
1.to sniff the messages sent on the serial port continuously
2.to run a set of selected iron python scripts and capture its output and display in text box.

Here i have no problem with sniffing the serial port(point 1). The problem is with capturing the ipy script output. I have done following to redirect the script output to a text box,
<br />
MIDL
engine = Python.CreateEngine();
runtime = engine.Runtime;
scope = engine.CreateScope();
AddAssemblies(runtime);
scope.SetVariable("tbScriptStatus", tbScriptStatus);
tbStream = new TextBoxStream(this.tbScriptStatus);
engine.Runtime.IO.SetOutput(tbStream, engine.Runtime.IO.InputEncoding);// Encoding.Default);


and to execute the script,

MIDL
source = engine.CreateScriptSourceFromFile(script_folder + "\\" + s);
source.Execute(scope);


The scripts executes fine. If i execute a simple scripts having only print statements, it works absolutely fine. Now, if i try executing scripts which open some other GUI which is under test, my application will freeze and i cannot do anything in my application until the script is completed. Once the script is completed, my application seems like working and all the output from the script can be seen in the text box tbScriptStatus. How can i avoid my application being freezed since i cannot see the script status while the script is being executed.

Thanks in advance,
Yogesh
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900