I am not getting how to combine two list producing tasks into a common list. The below code is incomplete and/or wrong, but I think will get my dilemma across. The OrderFactory requests data from an Internet server. Each OrderFactory completes at some future time and independent of any other OrderFactory. How can the List orders returned from each task be combined into one list? Both tasks are to start together but will return at a different future time.
TIA
private async Task<List<Orders>> GetReturnToOfficeOrdersAsync(PatientService patient)
{
var orders = new List<Orders>();
var x = await OrderFactory.CreateOrders(OrderType.RETURNTOOFFICE, patient);
orders.AddRange(x);
return orders;
}
private async Task<List<Orders>> GetProceduresAsync(PatientService patient)
{
var orders = new List<Orders>();
var x = await OrderFactory.CreateOrders(OrderType.PROCEDURE, patient);
orders.AddRange(x);
return orders;
}
private async Task GetInCompleteOrderListAsync()
{
if (patient == null) return;
var orders = new List<Orders>();
*** THE LISTS FROM THESE TASKS NEED TO BE COMBINED INTO ONE LIST -- HOW???
var a = GetReturnToOfficeOrdersAsync(patient);
var b = GetProceduresAsync(patient);
await Task.WhenAll(a, b);
orders = orders.OrderByDescending(o => o.torder).ToList();
IncompleteOrders = new ObservableCollection<Orders>(orders);
}