Skip to content

Instantly share code, notes, and snippets.

@AlphaGit
Created May 30, 2012 19:30
Show Gist options
  • Save AlphaGit/2838443 to your computer and use it in GitHub Desktop.
Save AlphaGit/2838443 to your computer and use it in GitHub Desktop.
Async without async
class Program
{
static void Main(string[] args)
{
long number = 4278;
var t = new Thread(() => FactorNumber(number, FactorizationDone));
t.Start();
t.Join();
Console.ReadKey();
}
static void FactorizationDone(ISet<long> result)
{
Console.WriteLine("The work is done, the results are: {0}", string.Join(", ", result));
}
static void FactorNumber(long number, Action<ISet<long>> callback)
{
var dividers = new SortedSet<long>();
for (long i = 1; i < number; i++)
{
if (number % i == 0)
dividers.Add(i);
}
callback(dividers);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment