-
|
Hi, I am currently using MimeMessage.LoadAsync inside a Parallel.ForEachAsync. Is this a thread safe operation? Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As long as the streams are not being used from multiple threads, yes. And it sounds like that's the case, so you should be good.
Right, but each call to That said, you could probably improve performance of your code if you instantiated 1 MimeParer per thread in your Parallel.ForEachAsync() logic and used parser.SetStream() and parser.ParseMessageAsync() instead of calling MimeMessage.LoadAsync(). |
Beta Was this translation helpful? Give feedback.
As long as the streams are not being used from multiple threads, yes. And it sounds like that's the case, so you should be good.
Right, but each call to
MimeMessage.Load/LoadAsync()creates its ownMimeParserinstance, so there's no possibility of multithreaded issues with the MimeParser.That said, you could probably improve performance of your code if you instantiated 1 MimeParer per thread in your Parallel.ForEachAsync() logic and used parser.SetStream() and parser.ParseMessageAsync() instead of calling M…