參考:https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/
https://github.com/dotnet/runtime/issues/16312
具體表現是代碼編譯很正常,但是在運行過程中,一旦觸發就會報異常:
System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Action`1.BeginInvoke(T obj, AsyncCallback callback, Object object)
嗯,就是 BeginInvoke 的鍋。。。
解決方案就是使用 Task.Run 來替換 BeginInvoke 即可,按文章里的說法,就是從 APM 換到 TAP,原來的這種方式不再推薦。