C# garbage collector and Subscribe in RabbitMQ
It was my understanding that .Net has a garbage collector that initiates clearing up memory at optimum time the garbage collection thinks is appropriate to start the clearing up. I am aware that this functionality of .NET comes in handy in memory management. However, due to security reasons there might be a time when you want the garbage collector to close connections, null up objects etc and you might have to manually do it. I have been having this bug that I couldn't close my console procedure in Main() for this reason. Main procedure thinks it's still in the connection via the opened channel but the program has completed its task long time ago. As I indicated above, I implemented a simple method that disposes all opened connections, channels, subscriptions etc. I then called this method at the end of the program for a safe exit. This simple method saves your program from breaking.