hozuki / MonoGame.Extended2

A collection of extensions for MonoGame
BSD 3-Clause Clear License
38 stars 8 forks source link

BeginInvoke - PlatformNotSupportedException on NET 5 #6

Open BrianBergh opened 3 years ago

BrianBergh commented 3 years ago

Hi. Im using MonoGame.Extended2 in my Memory3D Engine.

I reacently ported the original .NET Framework codebase to .NET 5 (Monogame 3.8 Core)

This gives an error when the video reaches the end, as of this line (apx line 540) Ended?.BeginInvoke(this, EventArgs.Empty, null, null); in MonoGame.Extended.VideoPlayback\DecodeContext.cs

is not suppored in NET 5.

I have found a workaround my self, and it seems to do the trick (everything works perfect in NET 5 now) Use Task.Run instead, works like a charm!

        // Must use BeginInvoke. See the explanations of Ended.
        // Ended?.BeginInvoke(this, EventArgs.Empty, null, null);
        Task.Run(() => // .NET 5 compatible as BeginInvoke is not supported
        {
          Ended?.Invoke(this, EventArgs.Empty);
        });

However, i have no clue on how to contribute to this repo :( If i could, i would do it.

Anyway, there is the solution - fully tested in NET 5, works perfect :P