想要在Listview中添加流程的标准输出
我正在从进程运行一个bat文件,想要在Listview中添加标准输出,我在下面编写了代码
public void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!string.IsNullOrEmpty(outLine.Data))
{
Trace.WriteLine(outLine.Data);
WriteInListBox(outLine.Data.ToString());
}
}
public delegate void WriteHandler(string s);
private void WriteInListBox(string text)
{
if (this.logText.InvokeRequired)
{
this.Invoke(new WriteHandler(WriteInListBox), new Object[] { text });
}
else
{
this.logText.Items.Add(Environment.NewLine + text);
}
}
现在它尝试第一次在listview中写入行,然后它永远不会出现在WriteInListBox函数中并挂起
I am running a bat file from process and want to add standard output in Listview for which I wrote code below
public void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!string.IsNullOrEmpty(outLine.Data))
{
Trace.WriteLine(outLine.Data);
WriteInListBox(outLine.Data.ToString());
}
}
public delegate void WriteHandler(string s);
private void WriteInListBox(string text)
{
if (this.logText.InvokeRequired)
{
this.Invoke(new WriteHandler(WriteInListBox), new Object[] { text });
}
else
{
this.logText.Items.Add(Environment.NewLine + text);
}
}
Now it try to write line in listview first time then it never comes in WriteInListBox function and hangs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论