I recently found myself needing a typesafe \"fire-and-forget\" mechanism for running code asynchronously.
Ideally, what I would want to do is somet
How about something like:
public static class FireAndForgetMethods
{
public static void FireAndForget(this Action act,T arg1)
{
var tsk = Task.Factory.StartNew( ()=> act(arg1),
TaskCreationOptions.LongRunning);
}
}
Use it like:
Action foo = (t) => { Thread.Sleep(t); };
foo.FireAndForget(100);
To add type safety, just expand out the helper methods. T4 is probably best here.