Skip to content
Discussion options

You must be logged in to vote

Is this a thread safe operation?

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.

I saw a previous issue "Thread-safety information" which mentioned that MimeParser is not thread safe which MimeMessage.LoadAsync uses internally.

Right, but each call to MimeMessage.Load/LoadAsync() creates its own MimeParser instance, 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…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ciranmc
Comment options

@jstedfast
Comment options

Answer selected by ciranmc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants