private async void btnCreate_Click(object sender, RoutedEventArgs e) { List <Guid> opIds; List <OperationStatus> opStatus; var tasks = new TaskModel[5]; tasks = GetTasks(); //Synchronous creation of tasks txtStatus.Text += "Starting synchronous task creation."; //start creating tasks and get the list of operation Ids opIds = new List <Guid>(); opStatus = new List <OperationStatus>(); foreach (TaskModel t in tasks) { try { opIds.Add(scheduledTask.CreateTask(t)); } catch (SchedulerModelValidationException me) { txtStatus.Text += "\n" + me.ExceptionMessage; //TODO: Log exception } catch (SchedulerException schedExp) { //TODO: Log exception } } txtStatus.Text += "\nGot operationIds, now checking status"; //get operation status for each operationId if (opIds.Count > 0) { try { opStatus = opIds.Select(t => scheduledTask.GetOperationStatus(t, true)).ToList(); } catch (SchedulerException shedExp) { //TODO: Log exception } if (opStatus.Count > 0) { DisplayOperationStatus(opStatus); } } txtStatus.Text += "\nEnding synchronous task creation."; //Asynsynchronous creation of tasks txtStatus.Text += "\nStarting asynsynchronous task creation."; //opIds = await CreatTasksAsync(); foreach (TaskModel t in tasks) { try { var currentOperationId = await scheduledTask.CreateTaskAsync(t); opIds.Add(currentOperationId); } catch (SchedulerModelValidationException me) { //write to log txtStatus.Text += "\n" + me.ExceptionMessage; } catch (SchedulerException exp) { //write to log } } txtStatus.Text += "\nGot operationIds, now checking status"; if (opIds.Count > 0) { foreach (Guid t in opIds) { try { var currentStatus = await scheduledTask.GetOperationStatusAsync(t, true); opStatus.Add(currentStatus); } catch (SchedulerException exp) { //write log } } if (opStatus.Count > 0) { DisplayOperationStatus(opStatus); } } txtStatus.Text += "\nEnding asyncsynchronous task creation."; }