【发布时间】:2021-11-07 15:36:24
【问题描述】:
在 c# wpf 中,我可以将基于命令行的应用程序添加到我的应用程序中,并使用 System.Diagnostics 在富文本框中发送输入和显示输出。现在我想在 ASP.NET MVC 中实现它。
我知道如何使用 ajax 将数据从 javascript 发送到控制器,并且控制器会进行一些处理并返回结果并将其显示在视图中。但问题是,来自该进程的数据正在通过这样的事件异步接收:
private void SortOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
// For each line that is printed in the console, this event will be executed and the
// text from that line can be received by outLine.data
}
我想要做的是将此接收到的文本 (outline.data) 异步添加到视图中的段落中。只有当我想运行 ActionResult 方法并等待我的响应并且在收到所有行之后,Ajax 才有效,然后它将结果发送回 javascript。但我想准确地显示每条收到的线路到达的那一刻。我该怎么做?
【问题讨论】:
标签: javascript c# asp.net-mvc model-view-controller