diff --git a/TUnit.Core/Executors/DedicatedThreadExecutor.cs b/TUnit.Core/Executors/DedicatedThreadExecutor.cs index f71b90cd7e..e3ab6ae470 100644 --- a/TUnit.Core/Executors/DedicatedThreadExecutor.cs +++ b/TUnit.Core/Executors/DedicatedThreadExecutor.cs @@ -77,11 +77,11 @@ private void ExecuteAsyncActionWithMessagePump(Func action, TaskCompl try { - var task = Task.Factory.StartNew(async () => + var task = Task.Factory.StartNew(static async action => { // Inside this task, TaskScheduler.Current will be our scheduler - await action(); - }, CancellationToken.None, TaskCreationOptions.None, taskScheduler).Unwrap(); + await ((Func)action!)(); + }, action, CancellationToken.None, TaskCreationOptions.None, taskScheduler).Unwrap(); // Try fast path first - many tests complete quickly // Use IsCompleted to avoid synchronous wait