Converting RTF-HTML – Not possible in a thread?

Been working on an application that needed to convert some RTF to HTML. Initially I thought this would be a reasonably simple requirement, and hoped that .Net might even include such a function to do this. Alas, I was being too optimistic.

So, trusting Google, ended up on this post from Matthew Manela – http://code.msdn.microsoft.com/Converting-between-RTF-and-aaa02a6e

Put that it, built the project, and ran on my UI thread, all works fine.

Put the same code in a background worker process or thread, and you will get an error: The calling thread must be STA, because many UI components require this.

The converter above unfortunately uses the built in RichTextBox component to perform a RTF-XAML conversion as the first step in the whole conversion process.

So, if anyone knows of a way that I can go from RTF-HTML in a separate thread from the UI, I would love to hear from you.

Be the first to like.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.