Code Questions

Dec 18, 2009 at 2:25 AM

Hi Keith,

I was looking at the code in the Router library, and stumbled onto something I don't understand, and was wondering if you could illuminate this code for me:

In the Listener.cs, under the ListenToEvents function:

                            for (i = 0; i < 10; i++)
                            {
                                try
                                {
                                    subscriptionMgrQueue.Enqueue(element);
                                    break;
                                }
                                catch (System.TimeoutException)
                                {
                                    continue;
                                }
                            }
Can you tell me why the element is queued 10 times?  The queueing part makes sense, but 10 seems kind of magical to me.
Thanks,
Sean
                            continue;

Coordinator
Dec 18, 2009 at 2:29 AM

It's not queued 10 times, only once but it will try up to 10 times before returning an error. If the enqueue succeeds, it breaks out of the for loop.

Dec 18, 2009 at 2:41 AM

Thanks - I hadn't seen that idiom before!