views:

21

answers:

0

I handled a click event to a button. It calls control1's animation function and control2' reloading content function. However, control1's animation will being "hanging" for a second while contorl2 is reloading content.

  1. How can I reload control2's content without blocking other controls on the UI?
  2. My second question is how can I use backgroundworder here to call a progressbar while "this.control2.content = TaskList" is processing? I have tried to use backgroundworker, but there always is an exception "This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread".

Thanks!

 void OnItemClick(object sender, RoutedEventArgs e)
    {

            this.control1.animation();
            Thread thread = new Thread(
                    new System.Threading.ThreadStart(
                        delegate()
                        {
                            this.control2.Dispatcher.BeginInvoke(
                                System.Windows.Threading.DispatcherPriority.Normal,
                                new Action(
                                    delegate()
                                    {
                                        this.control2.content = TaskList;
                                    }
                                ));
                        }
                  ));
            thread.Start();
    }