Advertisement
Guest User

async

a guest
Apr 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1.  private async Task RunAsync(CancellationToken cancellationToken)
  2.         {
  3.             try
  4.             {
  5.  
  6.                 WorkerQueue q = new WorkerQueue();
  7.                 // TODO: Replace the following with your own logic.
  8.                 while (!cancellationToken.IsCancellationRequested)
  9.                 {
  10.                     String peekedMessage = q.peekMessage();
  11.  
  12.                     if (peekedMessage != null)
  13.                     {
  14.                        
  15.                         Trace.TraceInformation(peekedMessage);
  16.  
  17.                         char delimitor = '*';
  18.                         String[] substrings = peekedMessage.Split(delimitor);
  19.                         Calc calc = new Calc();
  20.                         String price = calc.calculate(substrings[0], substrings[1], substrings[2], substrings[3]);
  21.  
  22.                         Trace.TraceInformation(substrings[0] + " " + substrings[1] + " " + substrings[2] + " " + substrings[3] + " " + price);
  23.  
  24.                         q.sendMessage(substrings[0], substrings[1], substrings[2], substrings[3], price);
  25.                     }
  26.                     Trace.TraceInformation("Working");
  27.                     await Task.Delay(1000);
  28.  
  29.                 }
  30.             } catch (Exception e)
  31.             {
  32.  
  33.             }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement