public WeatherInfoUsrCtrl() { InitializeComponent(); var dbg = EnvntCanadaScraper.FetchCurConds(true); Trace.WriteLine(MethodInfo.GetCurrentMethod().Name + " 1", DateTime.Now.ToLongTimeString()); launchScraper(); // Loaded += new RoutedEventHandler(WeatherInfoUsrCtrl_Loaded); Trace.WriteLine(MethodInfo.GetCurrentMethod().Name + " 2", DateTime.Now.ToLongTimeString()); }
void launchScraper() { Trace.WriteLine(MethodInfo.GetCurrentMethod().Name + " 1", DateTime.Now.ToLongTimeString()); tbHih.Text = tbCur.Text = tbLow.Text = "..."; var task = Task <EnvironmentCanadaData> .Factory.StartNew(() => EnvntCanadaScraper.FetchCurConds(true)); task.ContinueWith(_ => updateUI(task.Result), TaskScheduler.FromCurrentSynchronizationContext()); //tu: Get the UI thread's context Trace.WriteLine(MethodInfo.GetCurrentMethod().Name + " 2", DateTime.Now.ToLongTimeString()); }