Esempio n. 1
0
 public async Task <List <Materials> > GetMaterialsAll(string name = null)
 {
     return(await Task.Run(() =>
     {
         try
         {
             using (db = new ExmMaterialsDB())
             {
                 return db.Materials.ToList();
             }
         }
         catch (Exception)
         {
             return null;
         }
     }));
 }
Esempio n. 2
0
        private async void LoadMaterials()
        {
            //var a = await logic.ExtremistMaterialLogic.GetFoundedMaterials(new DateTime(), DateTime.Now);
            //a.FirstOrDefault().FoundMaterials.

            using (db = new ExmMaterialsDB())
            {
                materials = await Task.Run(() =>
                {
                    return(new ObservableCollection <FoundMaterials>(db.FoundMaterials.Include("Materials").ToList()));
                });
            }
            //materials =
            //materials = await new Task<ObservableCollection<FoundMaterials>> logic.ExtremistMaterialLogic.GetFoundedMaterials(new DateTime(), DateTime.Now);
            //await Task.Run(() =>
            //{


            //    App.Current.Dispatcher.Invoke((Action)delegate // <--- HERE
            //    {
            //        db = new ExmMaterialsDB();
            //        // Устанавливаем максимальное количество элементов
            //        bar = new MyProgressBar(db.FoundMaterials.Count());
            //        maxBar = bar.maxProgressBar;
            //        bar.WorkMethod += Bar_WorkMethod;
            //        bar.WorkCompleted += Bar_WorkCompleted;


            //        messageBar = $"{bar.valueProgressBar} / {bar.maxProgressBar}";
            //        query = db.FoundMaterials.OrderBy(i => i.Id);
            //        materials = new ObservableCollection<FoundMaterials>();

            //        bar.StartMethod();
            //    });

            //});
        }
Esempio n. 3
0
 private void Bar_WorkCompleted()
 {
     db = null;
 }