如何在 Interleave 中使用 PortMode.OptimizedSingleReissueReceiver? (微软 CCR)
我读过 Microsoft CCR 论坛上关于减少调用 Port.Post() 的开销的帖子 [参考:CCR 中的 PortElement 实例化] 我想知道是否有类似的方法将端口按顺序绑定到其接收器在交错仲裁器中以 OptimizedSingleReissueReceiver 模式使用端口?
我已经实现了以下代码,在 Interleave 上使用此 PortMode:
// Creates the Receiver
Receiver receiver = Arbiter.Receive(true, inputPort, inputPortHandler);
// Change the port mode before binding the Receiver with the DispatcherQueue
inputPort.Mode = PortMode.OptimizedSingleReissueReceiver;
// Creates the Interleave
ExclusiveReceiverGroup exclusiveReceiverGroup = new ExclusiveReceiverGroup(receiver);
Interleave interleave = Arbiter.Interleave(new TeardownReceiverGroup(),
exclusiveReceiverGroup,
new ConcurrentReceiverGroup());
// Activate the Interleave
Arbiter.Activate(dispatcherQueue, interleave);
起初,看起来没问题,但是我仍然不时遇到 NullReferenceException(此异常表明端口尚未绑定到接收器)。
有谁知道在 Interleave 内使用 PortMode.OptimizedSingleReissueReceiver 的另一种方法?
I have read a post on the Microsoft CCR forum on reducing the overhead of calls to Port.Post() [ref.: PortElement Instantiation in the CCR] and I was wondering if there is a similar way to bind a port to its receiver in order to use the port in OptimizedSingleReissueReceiver mode in an interleave arbiter?
I have implemented the following code do use this PortMode on an Interleave:
// Creates the Receiver
Receiver receiver = Arbiter.Receive(true, inputPort, inputPortHandler);
// Change the port mode before binding the Receiver with the DispatcherQueue
inputPort.Mode = PortMode.OptimizedSingleReissueReceiver;
// Creates the Interleave
ExclusiveReceiverGroup exclusiveReceiverGroup = new ExclusiveReceiverGroup(receiver);
Interleave interleave = Arbiter.Interleave(new TeardownReceiverGroup(),
exclusiveReceiverGroup,
new ConcurrentReceiverGroup());
// Activate the Interleave
Arbiter.Activate(dispatcherQueue, interleave);
At first, it seemed ok, however I still got NullReferenceException from time to time (this exception indicates that the port is not bound to a receiver yet).
Does anyone know another way to use PortMode.OptimizedSingleReissueReceiver inside an Interleave?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论