Show / Hide Table of Contents

Asynchronous Delegates

C# compiler adds BeginInvoke and EndInvoke methods for each custom delegate type. However, these methods throw NotSupportedException in .NET Core because they depend on .NET Remoting. You can read more about this limitation here.

.NEXT library provides alternative to these methods for asynchronous invocation of synchronous delegates. Extension method InvokeAsync which is located in AsyncDelegate class overloaded for commonly used delegate types from .NET library. The implementation executes every single method in the invocation list asynchronously because all delegates in C# are multicast delegates.

using DotNext.Threading;
using System;

Action action = Method1;
action += Method2;
action += Method3;

await action.InvokeAsync();
  • Improve this Doc
☀
☾
Back to top Generated by DocFX