I've got a strange question,and let's start from a piece of code:
foreach (var para in paras)
{
var specificSubject = string.Format(subject, paras);
_listener = new Listener(Queue.Default, transport, specificSubject, new object());
_listener.MessageReceived += OnMessage;
}
As you can see, I create a Tibco Listener object, subscribe it to some remote daemon and then, move the reference to the next Tibco Listener object I create.
I expect the Garbage Collector collects all the listener objects, except the last one, as _listener references it. However, running results suggest that ALL the listener objects are working.
So, why? Is is simply because I haven't run my application for long enough so that GC hasn't got time to collect the listener objects, or is there some inherent things that are referencing the "should-be-orphaned" listener objects?
Please enlighten me! Thanks.