title: Unity3d app for UWP freeze when using SerialDevice
body: <p>I have a piece of code that I want to use with Unity 2018.2.14.f1.</p>
  
  <pre class="lang-cs prettyprint-override"><code>#if UNITY_WSA &amp;&amp; !UNITY_EDITOR
  
  using System;
  using System.Collections.Generic;
  using System.Threading.Tasks;
  using Windows.Devices.Enumeration;
  using Windows.Devices.SerialCommunication;
  
  namespace SerialForUWP
  {
      public class SerialComHelper
      {
          public async static Task&lt;string[]&gt; GetPorts()
          {
              var serials = SerialDevice.GetDeviceSelector();
              var coms = await DeviceInformation.FindAllAsync(serials);
  
              List&lt;string&gt; results = new List&lt;string&gt;();
              foreach (var device in coms)
              {
                  using (var serialDevice = await SerialDevice.FromIdAsync(device.Id))
                  {
  
  
                      if (serialDevice != null)
                      {
                          var port = serialDevice.PortName;
                          results.Add(port.ToString());
                      }
                  }
              }
  
              return results.ToArray();
          }
      }
  }
  
  #endif
  </code></pre>
  
  <p>I compile for UWP using IL2CPP :</p>
  
  <p><a href="https://i.stack.imgur.com/QAC73.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QAC73.png" alt="enter image description here"></a></p>
  
  <p>I also already updated the manifest of the cpp projet :</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;DeviceCapability Name="serialcommunication"&gt;
    &lt;Device Id="any"&gt;
      &lt;Function Type="name:serialPort" /&gt;
    &lt;/Device&gt;
  &lt;/DeviceCapability&gt;
  </code></pre>
  
  <p>As soon as I try to use the GetPorts() function my app freeze.</p>
  
  <pre class="lang-cs prettyprint-override"><code>    void Update()
      {
          text.text = Time.time.ToString();
          if (Input.GetKeyUp(KeyCode.Space))
          {
              try
              {
  #if UNITY_WSA &amp;&amp; !UNITY_EDITOR
                  foreach (var com in SerialForUWP.SerialComHelper.GetPorts().Result)
                  {
                      text.text = com;
                  }
  #endif
              }
              catch (Exception ex)
              {
                  text.text = ex.ToString();
              }
  
          }
      }
  </code></pre>
  
  <p>I got no error, no exception.</p>
  
  <p>Can anyone help please ?</p>