domints

Untitled

Sep 22nd, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. var keepAlive = Task.Run(async () => {
  2.   while(!cancelSource.Token.IsCancellationRequested)
  3.   {
  4.     Console.WriteLine("Checking alive");
  5.     await Task.Delay(1000);
  6.     if(cancelSource.Token.IsCancellationRequested)
  7.       return;
  8.  
  9.     remoteStream.WriteByte(0xFF);
  10.     await remoteStream.FlushAsync().ConfigureAwait(false);
  11.     Console.WriteLine($"Flushing toilet. Connection is {_remoteClient.Connected}");
  12.   }
  13. }, cancelSource.Token);
  14.  
  15. //I get in console:
  16. //Flushing toilet. Connection is True
  17. //Checking alive
  18. // even after turning the device off
Advertisement
Add Comment
Please, Sign In to add comment