私のコードは次のとおりです。
static AutoResetEvent wait_till_finish = new AutoResetEvent(false);
...if (File.Exists("try.exe"))
{
Thread quartus_thread = new Thread(() => qar_function(@"\quartus");
quartus_thread.Start();
wait_till_finish.WaitOne();
// ONLY after command mode action was finished, and AutoResetEvent is set, lookfor some file in folder
if (File.Exists("def")) {//do something}
}
そして後で:
public void qar_function(string abc)
{ //does something...
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/k " + String.Join(" ", args));
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = false;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
// ***** now set AutoResetEvent:
wait_till_finish.set();
私の問題は次のとおりです。
1 つのメソッドに「wait_till_finish.WaitOne()」があり、Qar_Function メソッドを呼び出した後、待機状態になっているため、最初にメソッドを呼び出し、次にメソッドが実行されて終了するまで待機し、次に、qar_function メソッド内で AutoReset を設定します。
機能していません。
デバッガーを使用していますが、WaitOne で待機していません。次の行に移動し続けるだけです。
私は何を間違っていますか?どうも。