Im using SWT in my java code for my GUI and im executing a process that his code is written in python. Im using the process input stream in order to catch the prints on the process and writing them immediatly into my GUI.
my code:
in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
printToTerminal(line);
}
and the printToTerminal function:
protected void printToTerminal(String text) {
terminal.append(text + "\n");
terminal.redraw();
terminal.update();
}
The terminal is a Text object which i would like to append the text and then using redraw and update in order to show the line immediatly to the user. my problem is that my GUI is getting stucked because of that while loop which doing the job and getting the lines but i cant seem to get the solution for getting the lines without stucking my GUI. I tried using display.async function and include the while loop in there but it still didnt worked and my GUI got stucked.
Is there a way to getting the input stream for my process and printing it to my GUI without stucking it?
Thanks for the help.