
[英]Why does the UI thread get blocked when running something in a different thread?
[英]On iOS. When an app gets sent to the background, Is the app still running on the same UI thread or does it get moved to a new different thread
在iOS上。 当某个应用程序发送到后台时,该应用程序是否仍在同一UI线程上运行或是否移至新线程?
进入后台状态后,为您的应用分配的iOS线程池不会更改(当然,它们会被挂起)。
您可以通过检查NSThread.Current
来查看当前正在使用的NSThread.Current
。
如果您在DidEnterBackground
查看线程,是的,它是main
线程。
后台获取( PerformFetch
)将位于main
线程上。
基于后台的位置更新位于main
线程上。
即
switch (UIApplication.SharedApplication.ApplicationState)
{
case UIApplicationState.Background:
Console.WriteLine($"Background location update {NSThread.Current}");
break;
case UIApplicationState.Active:
Console.WriteLine($"Foreground location update {NSThread.Current}");
break;
}
Location[16904:1947553] Foreground location update <NSThread: 0x60000006d900>{number = 1, name = main}
Location[16904:1947553] Foreground location update <NSThread: 0x60000006d900>{number = 1, name = main}
Location[16904:1947553] Foreground location update <NSThread: 0x60000006d900>{number = 1, name = main}
Location[16904:1947553] App entering background state.
Location[16904:1947553] Now receiving location updates in the background
Location[16904:1947553] Background location update <NSThread: 0x60000006d900>{number = 1, name = main}
Location[16904:1947553] Background location update <NSThread: 0x60000006d900>{number = 1, name = main}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.