<PackageReference Include="NUnit" Version="4.5.0" />

NUnit.Framework.Internal.SafeSynchronizationContext

This context is used to protect test execution from any exceptions
public static SafeSynchronizationContext Create(SynchronizationContext synchronizationContext, TestExecutionContext executionContext)

Creates either a SafeSynchronizationContext or a SafeIndirectSynchronizationContext

protected void ExecuteSafely(SendOrPostCallback d, object state)

Executes the delegate safely, catching any exceptions and recording them in the test result.