/// <summary>
 /// Requests that an entity be called called back on the main thread.
 /// </summary>
 /// <param name="entity">The entity that is to be called back.</param>
 /// <param name="arg">The (optional) argument to pass to the entity.</param>
 public void RequestMainThreadCallback(IMainThreadEntity entity, object arg)
 {
     this.Dispatcher.Invoke(new MainThreadCallbackDelegate(this.doCallback), entity, arg);
 }
 /// <summary>
 /// Performs the main thread callback.
 /// </summary>
 /// <param name="entity">The entity that requested the callback.</param>
 /// <param name="arg">The argument to be sent to th entity.</param>
 private void doCallback(IMainThreadEntity entity, object arg)
 {
     entity.MainThreadCallback(arg);
 }