推 yeo1987: delegate(C#)->function pointer(C)的方式處理進度? 03/20 23:56
我嘗試在 c++ loop 中
cout 出來
並使用
Task.Run(
() =>
{
Process p = Process.GetCurrentProcess();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
while (true)
{
StreamReader sr = p.StandardOutput;
string strconsole = sr.ReadLine();
if (strconsole.Equals("Done"))
break;
}
});
不過 StandardOutput 卻出現錯誤
於 System.InvalidOperationException 擲回例外狀況: 'System.dll'
'System.InvalidOperationException' 類型的例外狀況發生於 System.dll,但使用者程
式碼未加以處理
其他資訊: StandardOut 尚未重新導向,或者處理序尚未啟動。
無法這樣使用嗎?
※ 編輯: b26168 (220.128.199.139), 03/21/2017 10:28:32
→ yeo1987: 你是想抓C# call C時Output的字串? 私心不建議這樣的模式 03/21 20:57
→ Litfal: 你是想抓自己程式link的C++ DLL的StdOut? 03/22 00:32
→ Litfal: 試試看用 SetStdHandle API 把-11或-12導到C#的PipeStream 03/22 00:40
→ disabledman: 怎不把流程控制放在上層 04/12 18:30