UWP/Windows 10 移动版中的 System.Threading.Thread 替换 [英] System.Threading.Thread replacement in UWP / Windows 10 mobile
问题描述
在 UWP 中,如何访问线程对象?我想更改我将管理的主线程和附加线程的名称.
In UWP, how can I access the thread object? I want to change the name of the main thread and additional thread that I will manage.
我还想在之后检查当前线程是否是主线程.
I also want to check if the current thread is the main thread afterwards.
我的目标是 Windows 10 移动版.以下代码示例适用于桌面,但不适用于手机(获取System.DllNotFoundException"):
I'm targeting to windows 10 mobile. The following code example works for desktop, but not for phone (getting 'System.DllNotFoundException'):
[DllImport("kernel32.dll")]
static extern IntPtr GetCurrentThread();
谢谢.
推荐答案
您应该使用任务而不是线程.https://msdn.microsoft.com/en-us/library/system.threading.tasks.task%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
You should use Tasks instead of threads. https://msdn.microsoft.com/en-us/library/system.threading.tasks.task%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
关于重命名线程,你能告诉我为什么需要重命名主线程和其他线程!?
As about renaming of threads, can you tell me why do you need to rename main thread and other threads!?
这篇关于UWP/Windows 10 移动版中的 System.Threading.Thread 替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!