Fix the issue that the application hangs when the preview button is clic...

@lukechurch

It is found that the application hangs when the preview button is clicked for some Revit nodes. The reason is that a main thread is waiting for a thread to complete which in turn is waiting for the main thread.

This submission checks whether the current thread is the main thread before it may cause the deadlock.