{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/o365rwsclient/issues/9","labels_url":"https://api.github.com/repos/Microsoft/o365rwsclient/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/o365rwsclient/issues/9/comments","events_url":"https://api.github.com/repos/Microsoft/o365rwsclient/issues/9/events","html_url":"https://github.com/Microsoft/o365rwsclient/issues/9","id":124752195,"number":9,"title":"Deadlock reachable from RetrieveData","user":{"login":"anirudhsanthiar","id":12654369,"avatar_url":"https://avatars.githubusercontent.com/u/12654369?v=3","gravatar_id":"","url":"https://api.github.com/users/anirudhsanthiar","html_url":"https://github.com/anirudhsanthiar","followers_url":"https://api.github.com/users/anirudhsanthiar/followers","following_url":"https://api.github.com/users/anirudhsanthiar/following{/other_user}","gists_url":"https://api.github.com/users/anirudhsanthiar/gists{/gist_id}","starred_url":"https://api.github.com/users/anirudhsanthiar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anirudhsanthiar/subscriptions","organizations_url":"https://api.github.com/users/anirudhsanthiar/orgs","repos_url":"https://api.github.com/users/anirudhsanthiar/repos","events_url":"https://api.github.com/users/anirudhsanthiar/events{/privacy}","received_events_url":"https://api.github.com/users/anirudhsanthiar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-04T12:33:34Z","updated_at":"2016-01-04T12:33:34Z","closed_at":null,"body":"The code below deadlocks o365rwsclient when invoked from a GUI app (such as a Windows Forms app) or an MVC appllication.\r\n```\r\n            ReportingContext context = new ReportingContext();\r\n            context.UserName = @\"YOUR O365 EMAIL ADDRESS\";\r\n            context.Password = @\"YOUR O365 PASSWORD\";\r\n            context.FromDateTime = DateTime.MinValue;\r\n            context.ToDateTime = DateTime.MinValue;\r\n            context.SetLogger(new DefaultLogger());\r\n\r\n            IReportVisitor visitor = new DefaultReportVisitor();\r\n\r\n            ReportingStream stream = new ReportingStream(context, \"MailboxActivityDaily\", \"stream1\");\r\n            stream.RetrieveData();\r\n```\r\n\r\nThe reason is that `RetrieveData` eventually calls `GetResponseXml`. The method\r\n`public List<XmlNode> GetResponseXml(Type reportType, QueryFilter filter)` has the line \r\n`Stream responseContent = GetResponseContentAsync(serviceFullUrl).Result;`\r\n\r\nBlocking on the results of asynchronous methods is dangerous: see, for example,\r\nhttp://blog.stephencleary.com/2012/07/dont-block-on-async-code.html\r\n\r\nA possible fix is to configure the awaits in `GetResponseContentAsync` to not capture context using `ConfigureAwait(false)`.\r\n\r\n\r\n\r\n"}}