How to create a Thread in windows phone 8.1

痞子三分冷 提交于 2019-12-25 18:56:53

问题


Hi, I've tried to create a Thread in windows phone 8.1 without success.

Althought in msdn documentation is written that Thread is supported, actually do not works (https://msdn.microsoft.com/en-us/library/274eh01d(v=vs.110).aspx)

so I can't figureout how can I create a Thread, I want to create a Syncronization context to execute async on a single thread (not current thread), but just to achieve what event loop do

thanks

update for further information:

I would be more specific:

platform is universal app, so I mean windows 8.1 & windows phone 8.1, no silverlight ecc.

I need to create a thread because I want to create a syncronization context to execute some async code, here is an example about what I mean http://blogs.msdn.com/b/pfxteam/archive/2012/01/20/10259049.aspx the difference from this link is I would use a specific thread for all async code instead current thread.

thanks again


回答1:


If you just want to run some code asynchronously, look into using Task.Run. It provides a much simpler mechanism than managing threads yourself.

If you are building an Universal Windows Phone 8.1 app, you can't use the .NET Thread type. If you need more control over the execution, you can use the WinRT ThreadPool.

Finally, if you really really need lots of control, there's always CreateThread if you want to write native code (this has recently been added to the allowed list of APIs for Store Apps, although MSDN isn't updated yet).



来源:https://stackoverflow.com/questions/28508492/how-to-create-a-thread-in-windows-phone-8-1

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