Search Unity

Are Threads supported for Hololens? Or should I use Task?

Discussion in 'VR' started by hitoruna, Oct 13, 2017.

  1. hitoruna

    hitoruna

    Joined:
    Jul 11, 2017
    Posts:
    19
    I am in the middle of a big confusion in my heard right now.

    First the questions: (later the explanation)
    1) Is Thread supported when building unity projects for the hololens?

    2) Can I use Task instead?

    ------------------
    1) I know that many people say Task is preferable than Threads but for the sake of argument allow me. I wrote a script that had thread to start a new thread. it worked well (in the unity player) . Now I want to try it in the hololens so I changed it to Windows STore and now it throws errors in compile

    Thread does not contain a constructor
    Thread does not contain Start
    Thread does not contain Sleep

    So is Thread supported for Windows store??

    2) If I can not use threads with the hololens, well maybe Tasks but I read that tasks are not supported. Or are they??

    Many thanks to anyone who can help me here
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    I believe you can use threads in UWP apps as long as you use the await operator and async keyword. Also, you might to try and use the 4.6 .NET framework in the player settings.
     
  3. hitoruna

    hitoruna

    Joined:
    Jul 11, 2017
    Posts:
    19
    After experiments and searching I finally managed to do it and draw the following conclusions:
    1) I can not use Threads in UWP. Instead I have to use Tasks.
    2) But wait...aren't Tasks unsupported? well, yes but you can still use them for apps for the Window Store. I just put some conditional compilation for anything related to tasks so that Unity does not complain but that will compile them for the window store. With that I think I managed to do it.