void Foo(int arg1, string arg2) { // Something to do in the background } // Asynchronously calling the Foo delegate BeginInvoke(new Action(Foo), 42, "hello");
void Bar(string arg1, int arg2) { // Some long running operation here } // Asynchronously calling the Bar delegate with a callback IAsyncResult asyncResult = BeginInvoke(new ActionThese examples use the `System.Threading` package library.(Bar), "world", 123, (result) => { Console.WriteLine("Callback called"); }); // The callback will be called when the Bar delegate completes running