I've been testing out ImapClient, and it seems whenever I attach an event handler to it (more specifically .NewMessage), it prevents .Search() from ever working. When I try calling .Search(), it'll throw a NotSupportedException inside of TextClient.GetResponse() with the message "The Read method cannot be called when another read operation is pending." It may be something related to using Ssl since I have it turned on and SslStream is in the stack trace, but I'm not sure.
Simply commenting out the .NewMessage line works. Commenting out the client.Search() line, adding Thread.Sleep(10000);, and receiving an email works (showing "New Mail!"). So both lines are functional, but .Search() isn't if .NewMessage is set.
Interestingly if I do something like this (where I temporarily remove the event handler), it works.
I've been testing out
ImapClient
, and it seems whenever I attach an event handler to it (more specifically.NewMessage
), it prevents.Search()
from ever working. When I try calling.Search()
, it'll throw aNotSupportedException
inside ofTextClient.GetResponse()
with the message "The Read method cannot be called when another read operation is pending." It may be something related to using Ssl since I have it turned on andSslStream
is in the stack trace, but I'm not sure.Anyways, here's an example.
Simply commenting out the
.NewMessage
line works. Commenting out theclient.Search()
line, addingThread.Sleep(10000);
, and receiving an email works (showing "New Mail!"). So both lines are functional, but.Search()
isn't if.NewMessage
is set.Interestingly if I do something like this (where I temporarily remove the event handler), it works.
So that's currently my workaround, but it's really counter-intuitive.