Advertisement
mahldcat

Untitled

Jul 29th, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. public object GetNextMessage(CancellationToken stopToken)
  2. {
  3.   CancellationToken timerToken = new CancellationToken();
  4.   timerToken.Register(() => {
  5.     //trigger a heartbeat message instead?
  6.   });
  7.  
  8.   CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(timerToken, timerToken);
  9.  
  10.   uint halfHour = (uint)(new TimeSpan(0, 30, 0)).TotalMilliseconds;
  11.   Timer t = new Timer((s) =>
  12.   {
  13.     cts.Cancel();
  14.   },null,halfHour,-1);
  15.  
  16.   return myMessage =_queue.Dequeue(cts.Token)
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement