コード例 #1
0
 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.");
 }
コード例 #2
0
 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.");
 }