System.Threading.Thread replacement in UWP / Windows 10 mobile

自作多情 提交于 2019-12-04 15:03:11

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!?

You should try System.Environment.CurrentManagedThreadId (yes, you can get only current thread id) https://msdn.microsoft.com/en-us/library/system.environment.currentmanagedthreadid(v=vs.110).aspx

We've blogged about this at length (as we feel this is an unwelcome start of the fragmentation of .NET Standard) and have published an open source System.Threading.Thread implementation for UWP/UAP 10, available on GitHub and via NuGet.

I hope this helps.

In UWP, you should look into using the classes from the Windows.System.Threading namespace. However, you will notice there is a thread pool, but no direct equivalent of the Thread class.

Remember that there are reasons why UWP does not allow you to just create a thread and leave it running for ever. That would make it too easy to drain the battery, but it would also get in the way of app suspension.

UWP has many mechanisms that allow you to do the kinds of things that on other platforms might be solved by using a dedicated thread. Maybe if you told us why you think you need a thread, we can help you in solving your actual problem?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!