3

Port.Post() [ref.: PortElement Instantiation in the CCR ]への呼び出しのオーバーヘッドを削減することに関する Microsoft 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 を使用する別の方法を知っている人はいますか?

4

0 に答える 0