Cross Thread Access to Object in ViewModel This is a fairly straight forward question. I have a C# WPF MVVM application that call a C++ DLL to do some compilation/crunching. To update the UI C# application for progress updates I am using callback delegates. 

public static class Callbacks
{
    public static ConsoleCallback ConsoleOutputCallback { get; set; }

    [UnmanagedFunctionPointer(CallingConvention.StdCall)]
    public delegate void ConsoleCallback(string message);
}


where the implementation is 

Callbacks.ConsoleOutputCallback = (message) =&gt; 
    {
        console.Document.Text += message;
    };


where Document is of type TextDocument. I am then passing this object into the C++ to be able to invoke it and update the UI. This works great, however, for one control I am getting a standard


  A first chance exception of type 'System.InvalidOperationException' ... TextDocument can be accessed only from the thread that owns it.


Now, I understand this error. To get around it I have done the following

TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext();
Callbacks.ConsoleOutputCallback = (message) =&gt; 
    {
        Task.Factory.StartNew(() =&gt;
        {
            console.Document.Text += message;
        }, CancellationToken.None,
           TaskCreationOptions.None,
           scheduler);
    };


which works. However, it would be nicer to look at if I could do a similar thing that I could do with a Control (which TextDocument Document is not) like 

public static void PerformSafely&lt;T&gt;(this Control target, Action&lt;T&gt; action, T parameter)
{
    if (target.InvokeRequired)
        target.Invoke(action, parameter);
    else
        action(parameter);
}


but I cannot do this with TextDocument as it does not inherit from Control. Is there a nicer way to do what I am doing?
The TPL is unfortunately verbose at times. The only way I can think of to make it look "nicer" is to point ConsoleOutputCallback to a named method and delegate the creation of the Task to another method:

public static void MyMethod()
{
    Callbacks.ConsoleOutputCallback = ConsoleOutputCallback;
}

public static void ConsoleOutputCallback(string message)
{
    var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

    Dispatch(
        msg =&gt; console.Document.Text += msg, 
        message, 
        scheduler
    );

    Dispatch(
        msg =&gt; someOtherNonControl.Text += msg,
        message,
        scheduler
    );
}

public static void Dispatch&lt;T&gt;(Action&lt;T&gt; action, T parameter, TaskScheduler scheduler)
{
    Task.Factory.StartNew(
        () =&gt; action(parameter), 
        CancellationToken.None, 
        TaskCreationOptions.None, 
        scheduler
    );
}