如何监控OmniThreadLibrary中的管道阶段? [英] How to monitor Pipeline stages in OmniThreadLibrary?
本文介绍了如何监控OmniThreadLibrary中的管道阶段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以以某种方式监控管道任务吗?我试图添加显示器到每个任务像这样
Is it possible to monitor Pipeline tasks somehow? I tried to add monitors to each task like this
FPipeline := Parallel.Pipeline()
.Stage(StageWorker1, Parallel.TaskConfig.MonitorWith(MyMonitor))
.NumTasks(MaxReadThreadCount)
.Stage(StageWorker2, Parallel.TaskConfig.MonitorWith(MyMonitor))
.Run();
但获取异常只能使用单个监视器监视任务(据了解,发生因为内部隐藏监视器已经安装了管道阶段)。
but getting the exception "Task can be only monitored with a single monitor" (as I understand, it happens because the internal hidden monitor is already installed for pipeline stages).
推荐答案
使用Parallel.TaskConfig.OnMessage并提供常见的消息处理功能。
Use Parallel.TaskConfig.OnMessage and provide a common message processing function.
FPipeline := Parallel.Pipeline()
.Stage(StageWorker1, Parallel.TaskConfig.OnMessage(MessageProc))
.NumTasks(MaxReadThreadCount)
.Stage(StageWorker2, Parallel.TaskConfig.OnMessage(MessageProc))
.Run();
procedure MessageProc(var msg: TOmniMessage);
begin
...
end;
MessageProc
可以是一个正常的过程或方法。
MessageProc
can be a normal procedure or a method.
这篇关于如何监控OmniThreadLibrary中的管道阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文