Skip to content

Instantly share code, notes, and snippets.

@SpeedOfSpin
Created January 8, 2018 15:59
Show Gist options
  • Save SpeedOfSpin/510897268803ca9ced2c7f8aaadef109 to your computer and use it in GitHub Desktop.
Save SpeedOfSpin/510897268803ca9ced2c7f8aaadef109 to your computer and use it in GitHub Desktop.
setTimeout equivalent in C#
var cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = cancellationTokenSource.Token;
Task.Delay(2000).ContinueWith(async (t) =>
{
//Do stuff
}, cancellationToken);
@Tomloyo
Copy link

Tomloyo commented Nov 2, 2023

works well without tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment