I have this code currently where each task calls an API:
asyncTasks = new List<Task>
{
itemDetailsOperation.Import(),
importPromotionsOperation.Update(),
importCripTransactionHistoryOperation.Import(),
importShelfTagTransactionHistoryOperation.Import(),
importClaimTransactionHistoryOperation.Import(),
importNaturalClaimTransactionHistoryOperation.Import(),
importPriceAuditTransactionHistoryOperation.Import(),
importOrdersOperation.Import(),
importAdNotificationsOperation.Import(),
importScheduledShipmentListOperation.Import(),
importDeliveryDepartmentOperation.Import(),
importDeliveryScheduleOperation.Import(),
importFutureShipmentItemsOperation.Import(),
importOrderGuidesOperation.Import(),
importClaimReasonCodeOperation.Import()
};
await Task.WhenAll(asyncTasks.ToArray());
And instead of throwing an exception (current logic) when one fails I would like to know which ones had a failed API call.
I tried looking at other related topics and tried doing the following code:
public class BaseTask : Task
{
public Boolean succeed;
public BaseTask()
{
}
}
but the compiler doesn't like it because "'Task' does not contain a constructor that takes 0 arguments". My thought was that once the API fails I can set the succeed flag to false and if it succeeds I can set it to true.
Then once all the tasks are complete I can retrieve all ones that failed.
Just looking for any thoughts or guidance!