title: Cannot await 'Void' even when using Task
body: <p>I have a problem. I am trying to modify an app I made some time ago and it Works still on WP Phone, but now I try to run it get these errors: </p>
  
  <p>On await I get:</p>
  
  <blockquote>
    <p>cannot await 'void'. </p>
  </blockquote>
  
  <p>When I change void to task the error is still </p>
  
  <blockquote>
    <p>Cannot await 'void' </p>
  </blockquote>
  
  <p>I don't even have <code>void</code> any more. </p>
  
  <p>Can somebody help me ?</p>
  
  <pre><code>namespace StreamUploadDownload
  {
      using System.Threading;
      public partial class Page1 : PhoneApplicationPage
      {
          private PhotoCamera _cam;
          private double _canvasWidth;
          private double _canvasHeight;
          private MediaLibrary _library = new MediaLibrary();
          public int count = 100;
          private static readonly string[] scopes = new string[] { "wl.signin", "wl.basic", "wl.offline_access", "wl.skydrive_update", "wl.skydrive" };
          string comboValue;
          private LiveConnectClient liveClient;
          public int x = 0;
          public int y = 0;  
  
          public string FileText { get; set; }
          public int ComboNumber { get; set; }
          public int ConnectionOK { get; set; }
  
          public Page1()
          {
              InitializeComponent();    
          }
  
          private void OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
          {
              this.liveClient = (e.Status == LiveConnectSessionStatus.Connected) ? new LiveConnectClient(e.Session) : null;
              if (e.Status == LiveConnectSessionStatus.Connected)
              {
                  btnSignin.Visibility = Visibility.Collapsed;
                  Pildista.Visibility = Visibility.Visible;
                  //Pildista2K.Visibility = Visibility.Visible;
                  Pildista.Content = "Pildista";    
              }
              else
              {
                  Pildista.Visibility = Visibility.Collapsed;
                  //Pildista2K.Visibility = Visibility.Collapsed;
                  btnSignin.Visibility = Visibility.Visible;
              }
          }    
  
          protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
          {
              if ((PhotoCamera.IsCameraTypeSupported(CameraType.Primary) == true) ||
                   (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) == true))
              {
                  if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
                  {
                      _cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
                      _cam.Initialized += new EventHandler&lt;CameraOperationCompletedEventArgs&gt;(cam_Initialized);
                      _cam.CaptureImageAvailable += new EventHandler&lt;ContentReadyEventArgs&gt;(cam_CaptureImageAvailable);
                      viewfinderBrush.SetSource(_cam);
  
                      //CameraButtons.ShutterKeyPressed += OnButtonFullPress;
  
                      base.OnNavigatedTo(e);
                      if (PhoneApplicationService.Current.State.ContainsKey("Text"))
                      {
                          txtvalue.Text = (string)PhoneApplicationService.Current.State["Text"];
                          FileText = txtvalue.Text;
                      }
                      if (PhoneApplicationService.Current.State.ContainsKey("index"))
                      {
                          ComboNumber = (int)PhoneApplicationService.Current.State["index"];
                      }
                      else
                      {
                          // The camera is not supported on the device.
                          this.Dispatcher.BeginInvoke(delegate()
                          {
                              // Write message.    
                          });
  
                          // Disable UI.    
                          AFButton.IsEnabled = false;    
                      }    
                  }
              }
          }
  
          private double GetCameraAspectRatio()
          {
              IEnumerable&lt;Size&gt; resList = _cam.AvailableResolutions;
  
              if (resList.Count&lt;Size&gt;() &gt; 0)
              {
                  Size res = resList.ElementAt&lt;Size&gt;(0);
                  return res.Width / res.Height;
              }
  
              return 1;
          }
  
          void cam_Initialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
          {
              if (e.Succeeded)
              {
                  this.Dispatcher.BeginInvoke(delegate()
                  {
                      _canvasHeight = Application.Current.Host.Content.ActualWidth;
                      _canvasWidth = _canvasHeight * GetCameraAspectRatio();
  
                      viewfinderCanvas.Width = _canvasWidth;
                      viewfinderCanvas.Height = _canvasHeight;
                  });
              }
          }   
  
          //Failinime andmine ning salvestamine.
          private async void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
          {
              if (ComboNumber == 1)
              {
                  comboValue = "O";
              }
              if (ComboNumber == 2)
              {
                  comboValue = "T";
              }
              if (ComboNumber == 3)
              {
                  comboValue = "S";
              }
              if (ComboNumber == 4)
              {
                  comboValue = "P";
              }
              if (ComboNumber == 5)
              {
                  comboValue = "A";
              }
              if (ComboNumber == 6)
              {
                  comboValue = "M";
              }
  
              string fileName = String.Format(FileText + "_" + comboValue + "_" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") + ".jpg");    
  
              try
              {    
                  LiveOperationResult operationResult = await this.liveClient.UploadAsync("/me/skydrive", fileName, e.ImageStream, OverwriteOption.Overwrite); //Cannot await 'void'    
              }
  
              catch (LiveConnectException ex)
              {
                  // e.ImageStream.Close();
                  // this.infoTextBlock.Text = "Error getting contact info: ";
                  // this.infoTextBlock.Visibility = Visibility.Visible;    
              }
              finally
              {    
                  e.ImageStream.Close();
                  y++;
                  Dispatcher.BeginInvoke(delegate()
                  {
                      string b = Convert.ToString(y);
                      loobvalue2.Text = b;
                  });    
              }    
          }    
  
          //kaameranupu vajutus.
  
          private void takephoto_Click(object sender, RoutedEventArgs e)
          {    
              if (_cam != null)
              {    
                  _cam.CaptureImage();
                  x++;
                  string s = x.ToString();
                  loobvalue.Text = s;    
              }    
          }   
  
          // Ühenduse Loomine. Session load.
          private async void connectButton_Click(object sender, RoutedEventArgs e)
          {
              bool connected = false;
              try
              {
                  var authClient = new LiveAuthClient("RemovedforWeb");
                  LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.skydrive" }); // cannot await 'void'
  
                  if (result.Status == LiveConnectSessionStatus.Connected)
                  {
                      connected = true;
                      var connectClient = new LiveConnectClient(result.Session);
                      var meResult = await connectClient.GetAsync("me");
                      dynamic meData = meResult.Result; //cannot await 'void'
                      }
                  else
                  {
                      //btnSignin.Visibility = Visibility.Visible;
                  }    
              }
              catch (LiveAuthException ex)
              {
  
              }
  </code></pre>
  
  <p>EDIT: I added more code, and commented on problematic places</p>