相关疑难解决方法(0)

使用TPL实现经典异步模式

我正在尝试为WF 4实现自定义TrackingParticipant.我可以编写Track方法,但我的实现速度很慢.

如何使用.NET 4.0的任务并行库(TPL)实现Begin/EndTrack覆盖?我看过TPL和Traditional .NET异步编程,但我不知道如何在这里应用它.

请注意,TrackingParticipant是.NET的一部分,并具有使用虚拟方法预定义的经典异步模式.

public class MyTrackingParticipant : TrackingParticipant
{
    protected override IAsyncResult BeginTrack(
        TrackingRecord record, TimeSpan timeout,
        AsyncCallback callback, object state)
    {
        // ?
    }

    protected override void EndTrack(IAsyncResult result)
    {
        // ?
    }

    protected override void Track(TrackingRecord record, TimeSpan timeout)
    {
        // synchronous code to be called
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asynchronous .net-4.0 workflow-foundation-4 task-parallel-library

10
推荐指数
1
解决办法
4150
查看次数