pchalamet/cassandra-sharp — pull request #73 by eplowe (2014-04-30 14:41:00+00:00)
Title: Memory Leak/Deadlock condition with LongRunningConnection

LongRunningConnection creates two tasks. One for reading a response from cassandra (ReadResponseWorker) and one for sending queries to cassandra (SendQueryWorker).
If there is an exception inside one of the those two methods HandleError is called which in turns calls the Close method. At the end of Close there are two lines of code:

```c#
ExceptionExtensions.SafeExecute(() => _responseWorker.Wait());
ExceptionExtensions.SafeExecute(() => _queryWorker.Wait());
```
If the exception happened in ReadResponseWorker then the first line will hang because you've essentially created a deadlock situation. The task can't complete because it's calling a method that is issuing a wait on the object that holds the task. This also stops the connection object from being garbage collected.