I'm no expert in this, but surely if you are using a static class then there
is not an instance of the class to dispose of, especially if the queue and
listener are also static, hence anything created in these static methods
will hang arround until it is explicitly disposed of, or the system is
closed down...
The only thing I can think of is to declare a static method in the Manager
class call somthing like TidyUp which closes everything down and tidies
up...
Alternativley, if it is practical, remove the static modifier on all items
of the class, create an instance of the Manager class and call your methods
on that, then when you close down things should tidy themselves...
"Guy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
>
>
> I'm using the following architecture:
>
> I have a singleton class (lets call it Manager class) that creates and
holds
> a reference to a BlockingQueue and a listener to that queue.
>
> The class sends the listener to listen to the queue in another thread to
> prevent the processing of the queue data to affect the main Thread
> execution.
>
>
>
> All the methods of the Manager class are static.
>
>
>
> The Manager class implements the IDisposable interface.
>
>
>
> The problem is that once the process is going down the Manager is not
> disposed so the queue the listener and the Manager stay stuck in the
> memory.
>
>
>
> The only solution I could find is to call the Manager Dispose method from
> another class's Dispose().
>
>
>
> Does anyone know how can I avoid this 'Spaghetti' coding and make the
> Manager class manage its own disposing?
>
>
>
> Guy
>
>
>
>
|