0

I'm trying to download a file from SkyDrive and have wrapped the Asynchronous calls in a Synchronous class. However when I'm call WaitOne everything is blocked and the EventHandeler never gets called.

 _client = new LiveConnectClient(connection.Session);
 _client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted);
 _client.GetAsync("me/skydrive/files");

 _autoEvent.WaitOne();  //get's stuck here client_GetCompleted never called.

....


void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
{
    ///do stuff
    _autoEvent.Set();
}
user1122052
  • 341
  • 1
  • 3
  • 10

2 Answers2

0

Remove the _autoEvent.WaitOne() call and the get completed event will be raised.

Igor Ralic
  • 14,975
  • 4
  • 43
  • 51
0

More than likely you are blocking the UI thread. (posting more code would help) Try running the first part in a new non-ui thread:

System.Threading.ThreadPool.QueueUserWorkItem(o =>
{
    _client = new LiveConnectClient(connection.Session);
    _client.GetCompleted +=
    new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted);
    _client.GetAsync("me/skydrive/files");

   _autoEvent.WaitOne();  //get's stuck here client_GetCompleted never called.

   <other code>
});
Jon
  • 2,891
  • 2
  • 17
  • 15