private void LoadData(string key, int pageIndex = 1, int pageSize = 10) { pbLoading.Visibility = Visibility.Visible; Task.Factory.StartNew(() => { var list = iBreedHomeService.GetPagerBreedHome(key, pageIndex, pageSize); var total = iBreedHomeService.GetBreedHomeCount(key); var pageCount = total / pageSize == 0 ? 1 : (total / pageSize) + (total % pageSize == 0 ? 0 : 1); ModelCollection = new BindableCollection <BreedHomeModel>(list); PagerModel = new PagerModel { TotalCount = total, PageCount = pageCount, DetailMsg = string.Format("[共{0}页/共{1}条]", pageCount, total) }; }).ContinueWith((task) => { System.Windows.Application.Current.Dispatcher.Invoke(new System.Action(() => { pbLoading.Visibility = Visibility.Collapsed; })); }); }