Example #1
0
        private void Select()
        {
            Task t = Task.Run(() =>
            {
                db      = new MOCK_DATA_DBEntities();
                counter = db.MOCK_DATA.ToList().Count;

                this.Dispatcher.Invoke(() =>
                {
                    var v = db.MOCK_DATA.Take(1000);
                    PersonView.ItemsSource = v.ToList();
                    //PersonView.ItemsSource =
                    this.Title = counter.ToString();
                });
            });
        }
Example #2
0
        private void Button_Click1(object sender, RoutedEventArgs e)
        {
            int tmp = Convert.ToInt32(Text.Text);

            Task t = Task.Run(() =>
            {
                db = new MOCK_DATA_DBEntities();

                var customers = db.MOCK_DATA;
                counter1      = 0;
                foreach (var i in customers)
                {
                    counter1++;
                    i.age += tmp;
                    if (counter1 % (counter / 100) == 0)
                    {
                        this.Dispatcher.Invoke(() =>
                        {
                            Bar.Value++;
                        });
                    }
                }
                MessageBox.Show("Start");
                this.Dispatcher.Invoke(() =>
                {
                    Ring.IsActive = true;
                });

                db.SaveChanges();
                this.Dispatcher.Invoke(() =>
                {
                    Ring.IsActive = false;
                });

                MessageBox.Show("Finish");
                this.Dispatcher.Invoke(() =>
                {
                    PersonView.ItemsSource = null;
                    Bar.Value = 0;
                });
                Select();
            });
        }