Created
June 4, 2012 22:01
-
-
Save clausjoergensen/2871084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method: | |
private Task<TextMessage> SendMessageToServiceAsync(TextMessage message) | |
{ | |
var tcs = new TaskCompletionSource<TextMessage>(); | |
SendMessageToService(message, (msg) => tcs.SetResult(msg)); | |
return tcs.Task; | |
} | |
Calling it this way: | |
TextMessage sentMessage = await SendMessageToServiceAsync(message); | |
OnMessageSentAction(sentMessage); | |
Getting following error: | |
"The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'." | |
But marking the method with async, and doing 'await tcs.Task' doesn't work either. Same error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment