ST-LINK_CLI.exeを使用してファームウェアをST-LINKにプログラムするアプリケーションがあります。プロセスの実行中にテキストを表示できません。C#WPF
ユーザがファームウェアを選択し、開始ボタンを押してプロセスが開始されます。しかし、ボードをプログラムするにはかなりの時間がかかり、ユーザーはプログラムがクラッシュしたと考えるかもしれません。テキストブロックに「ボードプログラミング...」を表示して、動作していることを知るようにします。
しかし、現時点では、プログラムは既にプログラムされていて、 。必ず、なぜ次は、[スタート]ボタンイベントに私のコードです:
ProcessStartInfo start = new ProcessStartInfo(); //new process start info
start.FileName = STPath; //set file name
start.Arguments = "-C -ME -p " + firmwareLocation + " -v -Run"; //set arguments
start.UseShellExecute = false; //set shell execute (need this to redirect output)
start.RedirectStandardOutput = true; //redirect output
start.RedirectStandardInput = true; //redirect input
start.WindowStyle = ProcessWindowStyle.Hidden; //hide window
start.CreateNoWindow = true; //create no window
using (Process process = Process.Start(start)) //create process
{
try
{
while (process.HasExited == false) //while open
{
process.StandardInput.WriteLine(); //send enter key
programmingTextBlock.Text = "Board Programming...";
}
using (StreamReader reader = process.StandardOutput) //create stream reader
{
result = reader.ReadToEnd(); //read till end of process
File.WriteAllText("File.txt", result); //write to file
}
}
catch { } //so doesn't blow up
finally
{
int code = process.ExitCode; //get exit code
codee = code.ToString(); //set code to string
File.WriteAllText("Code.txt", codee); //save code
}
は、プロセスの実行を開始またはプロセスが実行されている間、前に表示するテキストを取得するとにかくはあり
おかげ ?ルーシー
UIを操作し、あなたが別のthredを使用する必要がある時に何かを行うには。 – Whencesoever
どうすればこのことをやりますか? – lucycopp