NextFrame/NextWorldUpdate fails when nested
busheezy opened this issue · comments
It is not currently possible to nest NextFrame or NextWorldUpdate.
Server.NextFrame(() =>
{
Server.NextFrame(() =>
{
Logger.LogInformation("Crash!");
});
});
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at CounterStrikeSharp.API.Core.Helpers.InvokeNative(IntPtr ptr)
at CounterStrikeSharp.API.Core.ScriptContext.InvokeNativeInternal() in C:\Users\Michael\source\repos\CounterStrikeSharp\managed\CounterStrikeSharp.API\Core\ScriptContext.cs:line 114
at CounterStrikeSharp.API.Core.ScriptContext.Invoke() in C:\Users\Michael\source\repos\CounterStrikeSharp\managed\CounterStrikeSharp.API\Core\ScriptContext.cs:line 103
at CounterStrikeSharp.API.Core.NativeAPI.QueueTaskForNextWorldUpdate(InputArgument callback) in C:\Users\Michael\source\repos\CounterStrikeSharp\managed\CounterStrikeSharp.API\Core\API.cs:line 520
Additionally, a method RunOnTickCountN that allows you to schedule a task N ticks away would be great.
Additionally, a method RunOnTickCountN that allows you to schedule a task N ticks away would be great.
I've posted a workaround that comes with much overhead in the discord server long time ago, we could benefit for sure from a built-in internal way to do this^
I am adding the queued frame task nesting support in #365, would you be able to create the RunOnTick(int tick)
feature request as a separate issue?