private async void DownloadCurrentGDB(Exercise exercise, int key, Barrier downloadTrainingBarrier) { Console.WriteLine("S => Exercise id {0}, key = {1}, start at {2}", exercise.ExerciseId, key, DateTime.Now.ToString("hh:MM:ss.fff")); string json = await ApiConnection.GetExerciseGesturesApiAsync(exercise.ExerciseId); JSONConvertor.GettingExerciseGesture(exercise, json); using (DownloadCache dc = new DownloadCache(_currentPatient)) { dc.DownloadGDBfile(exercise); exercise.Downloaded = true; } if (key == FIRST_EXERCISE) //use for the first gdb - that exercise window can be upload (after splash) { finishFirstGDBSemaphore.Release(); } foreach (var item in _currentTraining.Playlist[key]) { if (!item.isDemo && !item.Equals(exercise)) { item.DBPath = exercise.DBPath; item.CopyGesturesFromOrigin(exercise); item.Downloaded = true; } } Console.WriteLine("F => Exercise id {0}, key = {1}, finish at {2}", exercise.ExerciseId, key, DateTime.Now.ToString("hh:MM:ss.fff")); downloadTrainingBarrier.SignalAndWait(); }
/// <summary> /// Retrive trainings detail from server (such id, all exercises list and etc.) /// </summary> private async void RetriveTrainingDetails() { try { //await _semaphoreSlime.WaitAsync(); if (!isErrorAccure) { Barrier barrier = new Barrier(_currentPatient.PatientTreatment.TrainingList.Count + 1); //downloading all the trainings data in the current treatment foreach (Training training in _currentPatient.PatientTreatment.TrainingList) { Task t = new Task(async () => { string trainingData = await ApiConnection.GetTrainingApiAsync(training.TrainingId); JSONConvertor.GettingPatientTraining2(training, trainingData); barrier.SignalAndWait(); }); t.Start(); } barrier.SignalAndWait(); //downloading current images for treatment screen using (DownloadCache _downloadCache = new DownloadCache(_currentPatient)) { _downloadCache.DownloadAllTreatmentImages(); } } } catch { //throw new Exception(); } finally { _semaphoreSlime.Release(); } }