3

我在 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 (此异常表明端口尚未绑定到接收器)。

有谁知道在交错中使用 PortMode.OptimizedSingleReissueReceiver 的另一种方法?

4

0 回答 0