如何在Interleave中使用PortMode.OptimizedSingleReissueReceiver? (微软CCR)

时间:2009-11-18 16:08:36

标签: port nullreferenceexception ccr

我已阅读Microsoft CCR论坛上有关减少调用Port.Post()[ref。:PortElement Instantiation in the CCR]的开销的帖子,我想知道是否有类似的方法将端口绑定到它的接收器是为了在交错仲裁器中使用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的另一种方式?

0 个答案:

没有答案