I'm updating/rewriting a C# program from .net 4.8 to .net 8, but the code uses a lot of Func .BeginInvoke() and .EndInvoke() calls, which no longer appear to be supported.
Question: What are some alternatives to Func - BeginInvoke(), assuming this cannot be fixed?
The exception caught:
System.PlatformNotSupportedException: 'Operation is not supported on this platform.'
Source: System.Private.CoreLib
StackTrace: at System.Func`1.BeginInvoke(AsyncCallback callback, Object object)...
Code example:
private static readonly Func> QueryUnprocessed =
(ctx) => from p in ctx.PAs
where !p.FaxOutTime.HasValue
&& !p.Duplicate
&& !p.IsLetter
&& !p.No_Process
&& !p.pa_type.Equals("D")
select p;
public static void GetUnprocessed(Action> callback)
{
Func> load = () =>
{
try
{
using (var ctx = PaEntities.NewContext())
{
var unprocessedPAs = QueryUnprocessed(ctx).ToList();
return unprocessedPAs.ToList();
}
}
catch (Exception e)
{
// TODO: Log error
return null;
}
};
// Error kicks off at BeginInvoke
load.BeginInvoke((ar) => callback(load.EndInvoke(ar)), null);
}