I'm getting a weird threading issue inside a SharePoint workflow that I'd like to learn more about. I'm trying to send an email using SPUtility.SendEmail asynchronously by firing up a new thread to do it. This successfully works at the end of a workflow for a summary email. I tried doing the same to replace a task notification email but ended up receiving the following error:
Microsoft.SharePoint.SPException: Attempted to make calls on more than one thread in single threaded mode.
The only difference I can think of is that the task is inside a replication activity so it can create several of these tasks (although testing this it's only creating just the one). What specifically is the replication activity doing behind the scenes that might cause this error when I try to spawn a new thread?
[NOTE] The reason I'm using threads to send the emails is because SPUtility.SendEmail is a blocking call, and in the case of a slow SMTP server the user might be getting their page back for up to a minute. And the reason I'm sending emails in the first place is because the standard task emails suck big time.