// Thread Runner public void run() { CancellationToken token = session.Token; //priceUpdate(); while (!token.IsCancellationRequested) //while (pCounter > 0) { Thread.Sleep(generator.Next(500, 2000)); try { if (pCounter > 0) { priceUpdate(); Console.WriteLine("\n-------- P Counter " + pCounter + " : Price $" + price + " --------"); } if (pCounter < 1 && buffer.isEmpty()) { session.Cancel(); } } catch (Exception e) { Console.WriteLine(" Server terminating. "); } } }