Hi, there are 3 ways to de-activate a receiver: 1) make the receiver one time, and the CCR will remove it after it processes one message, and it will do so automatically and atomically 2) use Arbiter.Choice to coordinate between receivers and the CCR will again remove all receivers after the first receiver executes 3) use Interleave and the TeardownReceiverGroup, and when a receiver in the group executes all other receivers will be removed
Ok there is actually one more way but its low level and youhave to be carefull when to use. If you look at the port API itself there is a Register and Unregister receiver, if you want to take matters on your own hands
Second question: Serializing calls
I strongly recommend to not use any calls to traditional thread locking APIS with the CCR. Use interleave, join constructs, activate one time receivers and then re-register them etc, to achieve serialization. Interleave is the most intuitive and takes care
of alot of conditions.
There are actually a few ways to achieve serialization with a system like the CCR, depending on what you are trying to do, but again interleave should allow you with a couple of lines, to serialize all access to apiece of code, even across asychnronous continuations
(if the exclusive receiver is an iterator)
hope this helps
Thanks a lot! I had a feeling that CLR thrddaing locking doesn't sound right! One more question: How does CCR works across domains? Can I register a receiver which is a callback to a remoting object and will be executed in a different domain? Do you see any problems in this scenario
First of all I want to thank you for the great library – I consider it one of the best pieces in .NET. I just started to learn it and have a few questions.
1. I have one port and I want dynamically to add and remove receiver. I understand that I can add receiver using Arbiter, for example by using Arbiter.Activate(dq, Arbiter.Receive(true, port, Handler<>). But how can I remove this receiver? Why there is
no method like Arbiter.Deactivate(….)?
2. In another scenario I have several ports and one receiver. How can I serialize calls to the delegate? Should I use Arbiter.Interleave (ExclusiveReceiverGroup) or I just can use lock(syncObject) in the receiver handler? Also, is there any way to dynamically
add/remove a receiver to a group?