static public async Task UpdateInventoryAsync() { while (!AllGetQueueFilled || inventoryUpdateQueue.Count > 0) { if (inventoryUpdateQueue.Count == 0) { await Task.Delay(500); } InventoryLevel p; if (inventoryUpdateQueue.TryDequeue(out p)) { try { if (p.InventoryItemId == null) { NotFoundIdInventoryUpdateQueue.Enqueue(p); } else { var result = await updateInventoryService.SetAsync(p); } } catch { GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}"); NotFoundIdInventoryUpdateQueue.Enqueue(p); } } } inventoryUpdateDone = true; GeneralAdapter.OutputString("inventoryUpdate Done."); }
static public void UpdateInventoryThread() { while (!AllGetQueueFilled || inventoryUpdateQueue.Count > 0) { InventoryLevel p; if (inventoryUpdateQueue.TryDequeue(out p)) { try { if (p.InventoryItemId == null) { NotFoundIdInventoryUpdateQueue.Enqueue(p); } else { var result = Task.Run(() => { return(updateInventoryService.SetAsync(p)); }).Result; } } catch { GeneralAdapter.OutputString($"This product was sent to check its Id {p.SKU}"); NotFoundIdInventoryUpdateQueue.Enqueue(p); } } } inventoryUpdateDone = true; GeneralAdapter.OutputString("inventoryUpdate Done."); }