I do simple test and problem is the same as before. Only when console app quits OutputHandler is executed and then I can read every line by line that app prints during running. Furthermore, it seems that StandardInput is not redirected because click on the button does not quit the app. App quits when 'e' key is pressed in the console window.
publicpartialclass MainWindow : Window
Process process = new Process();
privatevoid button_Click(object sender, RoutedEventArgs e)
textBox.Text += "test\r\n";
//* Create your Process
process.StartInfo.FileName = "c:\\ConsoleApp.exe";
process.StartInfo.Arguments = ".";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true;
//* Set your output and error (asynchronous) handlers
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
//* Start process and handlers
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
//* Do your stuff with the output (write to console/log/StringBuilder)
You need runCommand() to be in a worker thread .. it has to execute in the background so you can keep the WPF framework running in the foreground.
Look back at the windows code I had to do the same thing the CreateProcess(...) is inside a function which is spawned into it's own thread via CreateThread.
Unfortunately I don't use C# enough to know the code for making a worker thread off the top of my head.
I actually don't have the WPF framework installed on my VisualStudio at the moment to work it out.
Basically however we can describe it
1.) everything in runCommand() needs to go inside the worker thread start function .. when the thread starts it runs the app
2.) When the app finishes or your WPF app finishes you need to close the worker thread (LOOK at WM_DESTROY on the windows code)
So basically this worker thread will be chugging along in the background running the app but your program comes back to you to continue on to run the WPF framework.
So you job is to work out how to make a WPF worker thread and incorporate the code
OK, I know what you mean
For me, it is easier to use WPF because I am embedded system engineer.
I am from embedded world and I do not know Windows internals.
That is why I am asking a lot of (stupid) questions. After reading several articles I supposed that redirect output and develop GUI app should be easier
Now I know that my strange console app does not use standard printf function
The obvious question is can you not simply replace the program communicating with a proper windows code or is it a private format they won't disclose. Just saying it would be faster, cleaner and less code than what you are doing now
Yes, it is a private closed format.
Another way to communicate with the console app is passing command line arguments:
MyApp.exe -Iinput.txt -Ooutput.txt
where in the input.txt file in each line is a key command (e - exits the program, other keys do some actions):
in the output.txt file, the program saves its output. Even something like this works:
MyApp.exe -OCON - prints output to console twice.
But problem is the same. If I monitor the output file, the content appears after app quits (e command in input file)
This smells to me of buffering. I'm guessing your app doesn't call flush() or equivalent on its output file, so the output is buffered until the explicit or implicit close() call at termination.
If you can make your app output lots of data, you will probably see it appear in chunks, which will be whatever buffer size is used.
The reason it works on the console is that console drivers do not buffer.
I have no idea if you can suppress buffering in your redirection, but if you could, my 2c says that would solve your problem.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
i am trying to write a code to solve Laplace equation using Successive
Over relaxation(SOR)on a NXN matrix
boundary condition is X^2-y^2
i dont know how to set this boundary condition on the Mesh created by me
here is the code
import numpy as np
from pylab import *
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
L =[for i in range(2)]
N=int(input("Enter a number N for N x N grid: "))
x,y = np.meshgrid(xx,yy)
phi_new = copy.deepcopy(phi)
for w in np.linspace(1,2,11):
for i in range(1,N-1):
for j in range(1,N-1):
Sumresidual=0for i in range(1,N-1):
for j in range(1,N-1):
ax = plt.axes()
plt.ylabel('|| residual ||')
plt.title('effect of w on residual')
... anything. Guessing is not generally a good strategy for fixing problems. You need to be sure what the problem is first. Maybe if you show the code where the problem occurs, and a few more details, we could make some useful suggestions.
if stepped thru the code in Assembler after the function prologue by subtracting BP - SP = stack size right ?
I added code to a source file in Hercules cpu.c thing is its a makefile build which very confusing I was wondering if there isn't -F or /F flag for the stack size I guess it would default to some number my local variables and parameters would make the stack a little over 300 bytes, which is not too big
I am trying to figure to determine where in the makefile is the compile for CPU.C
I think we are talking at cross-purposes. What you are referring to is a function's frame size, which is a portion of the thread's stack. The frame will be created large enough for all the locally declared variables in that function, so you need to look at the source code to see why it is not large enough, or why it is being overwritten.
The makefile may be using an inference rule for cpu.c, so you cannot always find a specific line which references it. But you should be able to find a reference to it somewhere in the Makefile (or any of its included subfiles). However, as I mentioned, you still need to diagnose the actual problem, and changing the stack size for the final application is unlikely to make any difference.
The code works. But the output comes as stair steps. But, this is because of this sharpening .. and I want to alter . if you can give idea how to make the smoothing.
v2 is the velocity of second layer. and v1 is velocity of first layer.
maximum iterations is 10 with the percentage of threshold ..
problem is that it gives sharp stair stepping. while I want to make like smooth signal in output.
If you can guide.
Last Visit: 31-Dec-99 19:00 Last Update: 4-Dec-23 23:08