How to work with multithread for mail.dll? I always get error like this when fetching the data
"Limilabs.Client.ServerException: 'The Write method cannot be called when another write operation is pending.'"
I try to debug and the first method that cause the error
"Imap.GetBodyStructureByUID();"
It looks like GetBodyStructureByUID() not build for async, can you help me which method or workaround can be used for running fetch in multi thread?
// Bad code - do not use
await Task.Run(() =>
{
Parallel.ForEach(NewEmailHeaderIdList,
},
NewEmailHeaderId=>
{
List<BodyStructure> structures = Imap.GetBodyStructureByUID(NewEmailHeaderIdList);
string text = string.Empty;
string html = string.Empty;
if (structure.Text != null)
text = Imap.GetTextByUID(structure.Text);
if (structure.Html != null)
html = Imap.GetTextByUID(structure.Html);
}
);
}).ConfigureAwait(false);