【问题标题】:Long running process using TPL. Could not find how to write callback?使用 TPL 的长时间运行的进程。找不到如何编写回调?
【发布时间】:2012-03-17 17:38:24
【问题描述】:

我使用 TPL 来执行长时间运行的过程,例如在我的 asp.net 应用程序中生成 1,00,000 个 PDF。代码如下:

private Task<ErrorList> GeneratePDF()
{
    return Task.Factory.StartNew(

        --pdf generation goes here....
    )
}

谁能帮我做以下操作:

  1. 我想告诉 UI 到目前为止已经生成了多少 PDF。
  2. 一旦过程完成,我想显示一个弹出页面,其中包含 PDF 生成的所有详细信息。我找不到写回调的方法......

【问题讨论】:

    标签: asp.net user-interface callback task-parallel-library long-running-processes


    【解决方案1】:

    我认为您最好使用一种可以轮询您的网页/服务以了解进度和状态的架构。
    How To: Submit and Poll for Long-Running Tasks 是一个起点。

    这是另一个:Asynchronous processing in ASP.Net MVC with Ajax progress bar

    有关 TPL 相关的回调/进度报告,请参阅:Reporting Progress from Async Tasks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 2015-01-19
      • 2017-07-08
      • 1970-01-01
      相关资源
      最近更新 更多