2016-10-14 42 views
1

我在使用LinqToTwitter上傳視頻時遇到問題。我有一個示例代碼,它在Console application中調用時工作正常,但在WebForms項目中使用時會掛起。通過LinqToTwitter上傳媒體掛在WebForms中,在ConsoleApp中正常工作

private static ulong UploadMedia() 
{ 
    const string path = "c:\\Temp\\video.mp4"; 
    var authorizer = new SingleUserAuthorizer 
    { 
     CredentialStore = new SingleUserInMemoryCredentialStore 
     { 
      ConsumerKey = "my_consumer_key", 
      ConsumerSecret = "my_consumer_secret", 
      AccessToken = "my_access_token", 
      AccessTokenSecret = "my_access_token_secret" 
     } 
    }; 
    var tc = new TwitterContext(authorizer); 
    var media = UploadMediaAsync(tc, File.ReadAllBytes(path)).Result; 
    return media.MediaID; 
} 

private static async Task<Media> UploadMediaAsync(TwitterContext tc, byte[] media) 
{ 
    return await tc.UploadMediaAsync(media, "video/mp4"); 
} 

任何人都有一個想法出了什麼問題?

回答

相關問題