private static void loadSuplements() { plansEvent.Reset(); dictSuplements = null; var task = Task.Factory.StartNew(delegate { ControlHelper.EnsureThreadLocalized(); PagedResultRetriever retriever = new PagedResultRetriever(); var res = retriever.GetAll(delegate(PartialRetrievingInfo pageInfo) { try { return(ServiceManager.GetSuplements(pageInfo)); } catch (Exception) { plansEvent.Set(); throw; } }); dictSuplements = res.ToDictionary(t => t.SuplementId); plansEvent.Set(); }, null); LogUnhandledExceptions(task); }
private Task loadExercises() { exercisesEvent.Reset(); isLoading = true; dictExercises = null; var task = Task.Factory.StartNew(delegate { Helper.EnsureThreadLocalized(); PagedResultRetriever retriever = new PagedResultRetriever(); var res = retriever.GetAll(delegate(PartialRetrievingInfo pageInfo) { try { return(GetItemsMethod(pageInfo)); } catch (Exception) { exercisesEvent.Set(); throw; } }); dictExercises = new ConcurrentDictionary <Guid, T>(res.ToDictionary(t => t.GlobalId, n => n)); isLoading = false; exercisesEvent.Set(); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, dictExercises.Values.ToList())); }, exercisesEvent); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); task = LogUnhandledExceptions(task); return(task); }
private static void loadExercises() { exercisesEvent.Reset(); dictExercises = null; var task = Task.Factory.StartNew(delegate { ControlHelper.EnsureThreadLocalized(); PagedResultRetriever retriever = new PagedResultRetriever(); var res = retriever.GetAll(delegate(PartialRetrievingInfo pageInfo) { try { ExerciseSearchCriteria search = ExerciseSearchCriteria.CreatePersonalCriteria(); return(ServiceManager.GetExercises(search, pageInfo)); } catch (Exception) { exercisesEvent.Set(); throw; } }); dictExercises = res.ToDictionary(t => t.GlobalId); exercisesEvent.Set(); }, exercisesEvent); LogUnhandledExceptions(task); }
private static void loadPlans() { plansEvent.Reset(); dictPlans = null; var task = Task.Factory.StartNew(delegate { ControlHelper.EnsureThreadLocalized(); PagedResultRetriever retriever = new PagedResultRetriever(); var res = retriever.GetAll(delegate(PartialRetrievingInfo pageInfo) { try { WorkoutPlanSearchCriteria criteria = WorkoutPlanSearchCriteria.CreateFindAllCriteria(); criteria.SearchGroups.Remove(WorkoutPlanSearchCriteriaGroup.Other); var list = ServiceManager.GetWorkoutPlans(criteria, pageInfo); return(list); } catch (Exception) { plansEvent.Set(); throw; } }); dictPlans = res.ToDictionary(t => t.GlobalId); plansEvent.Set(); }, plansEvent); LogUnhandledExceptions(task); }
private void tbGenerateReport_Click(object sender, EventArgs e) { cancelGenerateReport = null; var selectedReport = SelectedReport; if (selectedReport != null) { clearReportControl(); cancelGenerateReport = ParentWindow.RunAsynchronousOperation(delegate(OperationContext context) { try { DateTime start = DateTime.Now; var criteria = selectedReport.GetWorkoutDaysCriteria(); criteria.UserId = User.Id; PagedResultRetriever retriever = new PagedResultRetriever(); var res = retriever.GetAll(delegate(PartialRetrievingInfo pageInfo) { return(ServiceManager.GetTrainingDays(criteria, pageInfo)); }); if (context.CancellatioToken.IsCancellationRequested) { return; } ParentWindow.SynchronizationContext.Send(delegate { selectedReport.GenerateReport(chart1, res); DateTime end = DateTime.Now; MainWindow.Instance.SetProgressStatus(false, ApplicationStrings.Reporting_GeneratingTimeStatus, (end - start).ToString()); }, null); } catch (Exception ex) { ParentWindow.TasksManager.SetException(ex); ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorCannotGenerateReport, ErrorWindow.MessageBox); } }, AsyncOperationStateChange); } }