Why is the thrown exception not printed in the background thread? #448
-
Why is the thrown exception not printed in the background thread? private async void RunTest()
{
Debug.LogError("RunTest:1");
Debug.LogError("ThreadId:"+Thread.CurrentThread.ManagedThreadId);
await PromiseYielder.WaitForRealTime(2);
await Promise.SwitchToBackgroundAwait();
Debug.LogError("ThreadId:"+Thread.CurrentThread.ManagedThreadId);
await PromiseYielder.WaitForRealTime(2);
Debug.LogError("cccc");
await Promise.SwitchToForegroundAwait();
Debug.LogError(Thread.CurrentThread.ManagedThreadId);
Debug.LogError("ttt");
await PromiseYielder.WaitForRealTime(2);
Debug.LogError("RunTest:2");
} |
Beta Was this translation helpful? Give feedback.
Answered by
timcassell
Jun 18, 2024
Replies: 1 comment 7 replies
-
Probably because you're using private void RunTest()
{
Run().Forget();
async Promise Run()
{
Debug.LogError("RunTest:1");
Debug.LogError("ThreadId:"+Thread.CurrentThread.ManagedThreadId);
await PromiseYielder.WaitForRealTime(2);
await Promise.SwitchToBackgroundAwait();
Debug.LogError("ThreadId:"+Thread.CurrentThread.ManagedThreadId);
await PromiseYielder.WaitForRealTime(2);
Debug.LogError("cccc");
await Promise.SwitchToForegroundAwait();
Debug.LogError(Thread.CurrentThread.ManagedThreadId);
Debug.LogError("ttt");
await PromiseYielder.WaitForRealTime(2);
Debug.LogError("RunTest:2");
}
} |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm guessing it has to do with the issue described in this forum thread: https://forum.unity.com/threads/suppressing-not-logging-exceptions-from-threadpool-and-async-void-methods-from-non-main-thread.1059491/