andyedinborough/aenetmail — Issue #15: InvalidOperationException on ImapClient.Dispose
Author: Waldo2k2
Created: 2011-12-29 18:16:19+00:00
State: open

After upgrading to version 1.5 from Nuget, I receive the following error when calling Dispose on an ImapClient:

System.InvalidOperationException was unhandled
Message=The collection has been marked as complete with regards to additions.
Source=System
StackTrace:
at System.Collections.Concurrent.BlockingCollection`1.TryAddWithNoTimeValidation(T item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Collections.Concurrent.BlockingCollection`1.Add(T item)
at AE.Net.Mail.TextClient.ReceiveData() in C:\repos\AE.Net.Mail\TextClient.cs:line 87
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

The exception is thrown from ReceiveData in TextClient after ReadThread.Join is called from Disconnect. When attempting to set a breakpoint the debugger refuses to break in the ReceiveData function before the exception is thrown, so I can't give you much more info than that.