Skip to content

Instantly share code, notes, and snippets.

@analogrelay
Created June 16, 2011 21:59
Show Gist options
  • Save analogrelay/1030397 to your computer and use it in GitHub Desktop.
Save analogrelay/1030397 to your computer and use it in GitHub Desktop.
Sleepsort for C#!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
var tasks = from arg in args
select new Thread(() => {
int val = -1;
if (Int32.TryParse(arg, out val)) {
Thread.Sleep(val * 1000);
Console.WriteLine(val);
}
});
foreach (var task in tasks) {
task.Start();
}
Console.ReadLine();
}
}
}
@pranavkm
Copy link

Remove and sort usings

@analogrelay
Copy link
Author

analogrelay commented Jun 16, 2011 via email

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