shmarya shmarya

Niner since 2006


  • CCR Programming - Jeffrey Richter and George ​Chrysanthak​opoulos

    Hi George,

    I have a question:

    I am trying to build a method which may be either asynchronous or synchronous, using CCR internally (to the method) to accomplish the asynchronousicity...

    So basically I have a method which has two local ports, one for the input message and the other for the returned results.

    Everything is fine until I want to block on the receiver for the result port in order to acheive 'synchronous' operation.

    How can I make the Activate call block?

    Is there a better method for doing this?


  • CCR Programming - Jeffrey Richter and George ​Chrysanthak​opoulos

    georgioc wrote:

    1. I assume you know upfront some pre determined count of messages otherwise its hard to tell which is last. You could use a timeout port etc, if you want to stop after a break in receiving messags. But in general a message could arrive at any time, even if there times where nothing is going on. Assuming you have a counter or some way to count you have two options:

       a) Use multipleItemReceive, and specify the number of items you expect. Then your handler will be executed when all N items are received
     b) use a one time Receiver once to run your handler as the first message arrives, increment a counter, then as long as count <Total, keep re-issuing the receiver, essentially throttling and waiting for the last message on your own
    c) use a persistent receiver in a exclusive block in an interleave, use a counter as in b), but then issue a teardown message to a receiver in the TeardownGroup

    Hi Georgio...

    I have a number of items which I want to execute 'concurrently', in addition, I want to be able to run specific code only when all the items have completed... I suppose I could use a multipleItemReceiver on a 'Response' port - IE. setup some persistent arbiter to run the work on the items concurrently, and then have each item post a response to the central Response port - then have the initial calling method register an arbiter with a choice between a timeout and a multipleItemReciever...

    In this case, how can I unregister the original receivers when a timeout occurs? I suppose I can put it all inside a single interleave... but I am not sure that is the best possible solution...

    One question regarding this: is the implementation of Port<> thread safe? IE, is it possible to post to it from multiple threads?

    Another (unrelated) question: How does the Ccr function across AppDomain/Process boundaries via Remoting? Are there any caveats I should be aware of?

  • CCR Programming - Jeffrey Richter and George ​Chrysanthak​opoulos

    Hi George!

    CCR is great, I'm really enjoying it!

    Two quick questions:

    1. How can I get some code to execute when the last item is removed from a port/dispatcherQueue? IE: I want to post a set of related workitems, yield, and continue only when all items have been dealt with...

    2. I have a set of related workitems which I post into a persistent port, I then go and set up an Interleave arbiter so that if one fails, the entire arbitration is torn down. How can I ensure that the items that where in the port's queue at the time the teardown occurs are popped out - IE: how can I make sure they won't be around the next time some Receivers are attached to the Port?