Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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