Beispiel #1
0
        //http://codereview.stackexchange.com/questions/42652/chaining-tasks-with-async-await
        public t.Task <CompanyFile[]> GetCompanyFiles(ApiConfiguration configuration, IOAuthKeyService authKeyService)
        {
            var tcs = new t.TaskCompletionSource <CompanyFile[]>();

            t.Task.Run(
                async() =>
            {
                var cfsCloud = new CompanyFileService(configuration, null, authKeyService);
                var files    = await cfsCloud.GetRangeAsync();
                tcs.SetResult(files);
            });
            return(tcs.Task);
        }
Beispiel #2
0
        private t.Task <OAuthTokens> GetOAuthTokens()
        {
            var tcs = new t.TaskCompletionSource <OAuthTokens>();

            t.Task.Run(
                async() =>
            {
                var oauthService = new OAuthService(_configurationCloud);
                var code         = OAuthLogin.GetAuthorizationCode(_configurationCloud);
                var response     = await oauthService.GetTokensAsync(code);
                tcs.SetResult(response);
            });
            return(tcs.Task);
        }