Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I'd love to see someone weigh on the technique shown in this post: Typesafe fire-and-forget asynchronous delegate invocation in C#Typesafe fire-and-forget asynchronous delegate invocation in C#

It looks like a simple extension method will handle all trivial cases of interacting with the tasks and be able to call dispose on it.

public static void FireAndForget<T>(this Action<T> act,T arg1) { var tsk = Task.Factory.StartNew( ()=> act(arg1), TaskCreationOptions.LongRunning); tsk.ContinueWith(cnt => cnt.Dispose()); } 

I'd love to see someone weigh on the technique shown in this post: Typesafe fire-and-forget asynchronous delegate invocation in C#

It looks like a simple extension method will handle all trivial cases of interacting with the tasks and be able to call dispose on it.

public static void FireAndForget<T>(this Action<T> act,T arg1) { var tsk = Task.Factory.StartNew( ()=> act(arg1), TaskCreationOptions.LongRunning); tsk.ContinueWith(cnt => cnt.Dispose()); } 

I'd love to see someone weigh on the technique shown in this post: Typesafe fire-and-forget asynchronous delegate invocation in C#

It looks like a simple extension method will handle all trivial cases of interacting with the tasks and be able to call dispose on it.

public static void FireAndForget<T>(this Action<T> act,T arg1) { var tsk = Task.Factory.StartNew( ()=> act(arg1), TaskCreationOptions.LongRunning); tsk.ContinueWith(cnt => cnt.Dispose()); } 
Source Link
Chris Marisic
  • 33.2k
  • 30
  • 169
  • 265

I'd love to see someone weigh on the technique shown in this post: Typesafe fire-and-forget asynchronous delegate invocation in C#

It looks like a simple extension method will handle all trivial cases of interacting with the tasks and be able to call dispose on it.

public static void FireAndForget<T>(this Action<T> act,T arg1) { var tsk = Task.Factory.StartNew( ()=> act(arg1), TaskCreationOptions.LongRunning); tsk.ContinueWith(cnt => cnt.Dispose()); }