I want to use TPL with an existing API, RestSharp, to be specific, so I can use extensions.
But that means that I need to wrap an API that does not use the classic .NET approach for async, but instead performs callbacks. Take some code:
var client = new RestClient("service-url"); var request = new RestRequest(); client.ExecuteAsync<List<LiveTileWeatherResponse>>(request, (response) => { ... });
So here I want to wrap ExecuteAsync in TPL, if possible. But I cannot for the life of me figure out how to do this.
Any ideas?
c # task-parallel-library restsharp
Claus jรธrgensen
source share