Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Universal 10 Build target, 'Thread' does not contain a constructor that takes 1 arguments

Discussion in 'Windows' started by wokawaka, Aug 10, 2016.

  1. wokawaka

    wokawaka

    Joined:
    Jan 11, 2014
    Posts:
    12
    I just changed my build target to Windows Store Universal 10.
    Upon doing so the project no longer compiles.
    This is the error I'm getting:
    This code works on Android, so I'm assuming the Universal 10 target uses some other subset of .Net.
    This is the code thats generating the error.
    Code (CSharp):
    1. var t = new System.Threading.Thread(() =>
    2. {
    3.     // do slow network stuff that freezes UI thread here.
    4. });
    5. t.Start();
    My question is then what version of .Net is this, and what should I do to avoid the problem.

    P.S. I believe this also worked on the WP 8.1 target.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    It uses .NET Core 5 when you're using .NET scripting backend. I don't think with ever worked on WP8.1 as that uses a similar subset.

    If you switched to IL2CPP scripting backend, it would use .NET 3.5 subset, the same as any other Unity platform (including the editor or android). I suggest you try that as that's the easiest solution without you having to rewrite your code.
     
  3. wokawaka

    wokawaka

    Joined:
    Jan 11, 2014
    Posts:
    12
    Switching to IL2CPP solved the issue. Thanks.
     
  4. Rajbib

    Rajbib

    Joined:
    Jan 26, 2017
    Posts:
    2
    Hello all,
    i am having the same issue. 'Thread' does not contain a constructor that takes 1 arguments and i don't want to switch to IL2CPP i want to continue using .NET. Can some one explain how to avoid this problem while continuing to use .NET scripting background
     
  5. ClaytonOne

    ClaytonOne

    Joined:
    Sep 5, 2015
    Posts:
    89
    I don't think Thread exists in .NET Core. Instead you can use ThreadPool.RunAsync or Task.Run. If used in your Unity code they need to be in #NETFX_CORE defines
     
  6. Rajbib

    Rajbib

    Joined:
    Jan 26, 2017
    Posts:
    2
    Thank you