I have got this code. It works but it freezes the UI.
What I want to know is how to use WPF BeginInvok method corectly?
private void ValidateAuthURL_Click(object sender, RoutedEventArgs e)
{
((Button)sender).Dispatcher.BeginInvoke(DispatcherPriority.Input,
new ThreadStart(() =>
{
bool result = false;
try
{
Your delegate is going to be executed in the UI thread. That’s what
Dispatcher.BeginInvokeis there for. I assume you really want to execute that delegate in a background thread… then you should useDispatcher.BeginInvoketo get back to the UI thread in order to update the UI later.In terms of getting to a background thread, you could:
ThreadPool.QueueUserWorkItem)BackgroundWorkerTask.Factory.StartNew(if you’re using .NET 4)