Task.Run(() => Method()); doesn't run the method?
<p>In my WPF application:</p>

<pre><code>using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using System.Diagnostics;

namespace CloudKey
{
/// &lt;summary&gt;
/// Interaction logic for Page1.xaml
/// &lt;/summary&gt;
public partial class Page1 : Page
{
    public Page1()
    {
        InitializeComponent();

        AuthText.Visibility = Visibility.Hidden;

    }
    private async void button_Click(object sender, RoutedEventArgs e)
    {

        AuthText.Visibility = Visibility.Visible;
        await Task.Run(() =&gt; Authenticate());
        Task.Factory.StartNew(() =&gt; Authenticate());
        Task.Run(() =&gt; Authenticate());
        Authenticate();
    }
    void Authenticate()
    {
        //Do Stuff
    }
  }
}
</code></pre>

<p>No matter which way I try to call <code>Authenticate</code> with <code>Tasks</code> it just doesn't run. Am I using <code>Task</code> wrong?</p>

<p>Using await (and async) causes an exception to be thrown:</p>

<p>System.InvalidOperationException was unhandled
Message: An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: The calling thread cannot access this object because a different thread owns it.</p>

<p>Using just Task.Run or Task.Factory.StartNew causes the Authenticate method not to be run at all.  If I add a breakpoint to the Authenticate method it isn't reached.</p>

<p>Just calling the method with Authenticate() runs the entire method without issue, but it freezes the UI making "AuthText.Visibility = Visibility.Visible;" useless.</p>

<p>To be honest, I really just want the UI to update with the message "Authenticating..." and THEN run everything in the method when I click the button. Is there perhaps an easier way to do that?</p>

<p>THIS IS THE WORKING CODE FOR REFERENCE:</p>

<pre><code>using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Win32;
using System.Diagnostics;
using System.Threading.Tasks;

namespace CloudKey
{
/// &lt;summary&gt;
/// Interaction logic for Page1.xaml
/// &lt;/summary&gt;
public partial class Page1 : Page
{
    public Page1()
    {
        InitializeComponent();

        //private void PasswordBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { button_Click } }
        AuthText.Visibility = Visibility.Hidden;

    }
    private void button_Click(object sender, RoutedEventArgs e) //ON CONTINUE BUTTON CLICK
    {
        AuthText.Visibility = Visibility.Visible;
        Task.Run(() =&gt; Authenticate());
    }
    void Authenticate()
    {
        Dispatcher.Invoke(
        () =&gt;
        {
          //ALL MY CODE HERE;
        });
      }
    }
  }
</code></pre>