ikeough/Dynamo — pull request #892 by Benglin (2013-12-05 02:30:54+00:00)
Title: Fix unit test case: VisualizationInSyncWithPreviewUpstream

Background
==========
A **Dispatcher.Invoke** call was made to fix the following exception, when evaluation thread calling **ValidateConnections** that eventually led to UI update and crash Dynamo.

[MAGN-847 Info bubble causing UI threading exception](http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-847)

The problem is, **Invoke** call schedules an action to be called on UI thread's dispatcher synchronously (i.e. this method doesn't return until it gets dispatched on the UI thread and execute). This would work on a regular user scenario, but in N-Unit where dispatcher is not pumping messages in its queue, the method does not get a chance to run. The **Dispatcher** for that thread is killed as unit test case **VisualizationInSyncWithPreviewUpstream** timed out after 1 second, causing it to fail.

In order to fix this issue, **Dispatcher.BeginInvoke** is used instead. This call schedules the **Action** to run on UI thread asynchronously, unlike **Invoke** method, **BeginInvoke** returns immediately, allowing the test case to proceed successfully.

Future direction
================

The proper fix is being developed on **ChocoButterUI** branch, and will be tested shortly. The idea is to raise **property change events** from **InfoBubbleViewModel** rather than causing a direct update on **InfoBubbleView**. When that proper fix gets in, this **Dispatcher.BeginInvoke** will no longer be required and can be completely removed.

Unit testing
============
* Tested the defect fix and it continues to work
* Test case **VisualizationInSyncWithPreviewUpstream** is now passing with the fix