开发者

How to use PortMode.OptimizedSingleReissueReceiver in an Interleave? (Microsoft CCR)

开发者 https://www.devze.com 2022-12-11 15:34 出处:网络
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 si开发者_如何学Cmilar way

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 si开发者_如何学Cmilar 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号