Action myAction = () => Console.WriteLine("Hello, World!"); IAsyncResult result = myAction.BeginInvoke(null, null); myAction.EndInvoke(result);
ActionThis example creates an instance of the Action delegate that takes a boolean parameter and prints the value to the console. It then calls the BeginInvoke method to execute the delegate asynchronously with the value "true" as the parameter. The EndInvoke method is called to retrieve the results of the operation, which is stored in the variable "returnValue". The System Action EndInvoke method is part of the System.Core.dll package library.myAction = (bool b) => Console.WriteLine("The result is: " + b.ToString()); IAsyncResult result = myAction.BeginInvoke(true, null, null); bool returnValue = myAction.EndInvoke(result);