title: The await operator can only be used within an async method
body: <p>I have an interface <code>ISFactory</code> as follows.</p>
  
  <pre><code>namespace MyApp.ViewModels
  {
      public interface IStreamFactory
      {
          Stream CreateSPStream(string sPName);
      }
  }
  </code></pre>
  
  <p>On Windows non-universal version the above function was implemented as follows.</p>
  
  <pre><code>public Stream CreateSerialPortStream(string serialPortName)
  {
      var p = new System.IO.Ports.SerialPort();
      p.PortName = serialPortName;
      p.BaudRate = 9600;
      p.RtsEnable = true;
      p.DtrEnable = true;
      p.ReadTimeout = 150;
      p.Open();
      return p.BaseStream;
  }
  </code></pre>
  
  <p>This implementation is no longer available in Windows Universal. What I attempted is shown below.</p>
  
  <pre><code>public  Stream CreateSerialPortStream(string serialPortName)
  {
      var selector = SerialDevice.GetDeviceSelector(serialPortName); //Get the serial port on port '3'
      var devices = await DeviceInformation.FindAllAsync(selector);
      if (devices.Any()) //if the device is found
      {
          var deviceInfo = devices.First();
          var serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id);
          //Set up serial device according to device specifications:
          //This might differ from device to device
          serialDevice.BaudRate = 19600;
          serialDevice.DataBits = 8;
          serialDevice.Parity = SerialParity.None;
      }
  }
  </code></pre>
  
  <p>I get the following error.</p>
  
  <blockquote>
    <p>The await operator can only be used within an async method.`</p>
  </blockquote>
  
  <p>Can anyone suggest a way around this.</p>