Invoking the BeginInvoke method of a MulticastDelegate derived delegate compiles fine with .NET Core, but throws a NotSupportedException.
Should this really be the case?
Sample code is here, .NET 4.6 runs ok, but .NET Core fails with the mentioned exception:
https://github.com/ProfessionalCSharp/ProfessionalCSharp6/tree/master/Synchronization/SynchronizationSamples/AsyncDelegate
Thanks,
Christian
Async delegates are not in .NET Core for several reasons:
Can't this be solved by compilation errors instead of runtime exceptions?
@jaredpar What do you think?
Generally the compiler enables / disables features by looking at the types for hints. Is there anything we can key on here to know to exclude these members?
just refreshing this thread to see if something can be done for compilation errors instead of runtime exceptions
+1 For compiler safety. How does it make sense to make an API available that is guaranteed to be the wrong thing to use? The ideal experience is for BeginInvoke
not to exist on core.
Linking back to the official blog post, in case someone comes across the github issue before finding the post. It has some more details and suggestions how to replace Delegate.BeginInvoke
invocations.
https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/
Most helpful comment
+1 For compiler safety. How does it make sense to make an API available that is guaranteed to be the wrong thing to use? The ideal experience is for
BeginInvoke
not to exist on core.