TwitterResponse causes hang on Silverlight
-
12-04-2021 - |
Question
Whenever I try and make any Twitter request, my application always hangs. This does not apply to the oAuthUtility though, I have successfully authorized the user to use my application, but whenever I make a request it just hangs. Here is one of the requests I am making that hangs:
Dim response As TwitterResponse(Of TwitterStatus) = TwitterStatus.Update(myFire_tokens.Tokens, TextBox1.Text)
If response.Result <> RequestResult.Success Then
MessageBox.Show(response.ErrorMessage, "Error", MessageBoxButton.OK)
Else
MessageBox.Show("Tweet Sent", "Awesome!", MessageBoxButton.OK)
End If
This hang occurs on Version 2.4, and releases: 504, 516, and 523. On Silverlight 5 and 4. The problem I belive lies with TwitterResponse because the method does get called (For example if I ran the above code, the tweet would post) because I can see a OK response in Fiddler.
No exceptions are thrown in the debugger, the application just hangs.
Solution
You should link against the SilverlightAsync project.
If you are on the Silverlight-side, it would have used this signature:
public static IAsyncResult Update(
OAuthTokens tokens,
string text,
StatusUpdateOptions options,
TimeSpan timeout,
Action<TwitterAsyncResponse<TwitterStatus>> function)
notice the additional two parameters?
Your code should look something like this
TwitterStatus.Update(
myFire_tokens.Tokens,
TextBox1.Text,
Nothing,
0,
Sub (response As TwitterAsyncResponse<TwitterStatus>)
If response.Result <> RequestResult.Success Then
MessageBox.Show(response.ErrorMessage, "Error", MessageBoxButton.OK)
Else
MessageBox.Show("Tweet Sent", "Awesome!", MessageBoxButton.OK)
End If
End Sub)