using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace DispatcherExamples
{
    /// <summary>
    /// Interaction logic for AvoidWait.xaml
    /// </summary>

    public partial class AvoidWait : System.Windows.Window
    {

        public AvoidWait()
        {
            InitializeComponent();
        }

        delegate void MyDelegateType();

        private void BackAndForth()
        {
            // Example C-4. Avoiding Wait and Completed

            MyDelegateType work = delegate
            {

                DoWorkOnUIThread();

                DoWhateverWeNeedToDoNowTheMainWorkHasBeenDone();
            };
            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, work);

            // End of Example C-4.
        }

        private void DoWhateverWeNeedToDoNowTheMainWorkHasBeenDone()
        {
            
        }

        private void DoWorkOnUIThread()
        {
        }
    }
}