Skip to content

Instantly share code, notes, and snippets.

@i3arnon
Last active October 6, 2015 21:05
Show Gist options
  • Save i3arnon/9f4e2f5044c89662911a to your computer and use it in GitHub Desktop.
Save i3arnon/9f4e2f5044c89662911a to your computer and use it in GitHub Desktop.
High contention when creating new timers
static void Main()
{
for (var i = 0; i < Environment.ProcessorCount; i++)
{
Task.Factory.StartNew(() =>
{
while (true)
{
new Timer(_ => { }, null, TimeSpan.FromMilliseconds(100), Timeout.InfiniteTimeSpan);
}
}, TaskCreationOptions.LongRunning);
}
Console.ReadLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment