using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Threading;
using Telerik.Windows.Diagrams.Core;

namespace AsyncDigrams
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();

			BackgroundWorker worker = new BackgroundWorker();

			worker = new BackgroundWorker();
			worker.DoWork += this.OnWorkerDoWork;
			worker.RunWorkerCompleted += this.OnWorkerRunWorkerCompleted;

			worker.RunWorkerAsync();
		}

		private void OnWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
		{
			this.myDiagram.GraphSource = e.Result as IGraphSource;
		}

		void OnWorkerDoWork(object sender, DoWorkEventArgs e)
		{
			System.Threading.Thread.Sleep(TimeSpan.FromSeconds(4));
			e.Result = new MySource();
		}
	}
}
