private async void RequestData(string uri, Action<string> action)
{
var client = new WebClient();
string data = await client.DownloadStringTaskAsync(uri);
action(data);
}
More Related Contents:
- Is it possible to await an event instead of another async method?
- How and when to use ‘async’ and ‘await’
- How to call asynchronous method from synchronous method in C#?
- How would I run an async Task method synchronously?
- Parallel foreach with asynchronous lambda
- await Task.Run vs await
- Asynchronous locking based on a key
- What is the difference between await Task and Task.Result?
- Parallel.ForEach vs Task.Run and Task.WhenAll
- Why is HttpContext.Current null after await?
- Suppressing “warning CS4014: Because this call is not awaited, execution of the current method continues…”
- Get TransactionScope to work with async / await
- Enforce an async method to be called once
- What is the use for Task.FromResult in C#
- awaitable Task based queue
- Struggling trying to get cookie out of response with HttpClient in .net 4.5
- Running async methods in parallel
- Different forms of the WCF service contract interface
- Is async HttpClient from .Net 4.5 a bad choice for intensive load applications?
- Accessing UI controls in Task.Run with async/await on WinForms
- Download multiple files async and wait for all of them to finish before executing the rest of the code
- Should I worry about “This async method lacks ‘await’ operators and will run synchronously” warning
- Is .GetAwaiter().GetResult(); safe for general use?
- Task.Factory.StartNew with async lambda and Task.WaitAll
- async await performance?
- can not await async lambda
- How to cancel await Task.Delay()?
- Using async / await with DataReader ? ( without middle buffers!)
- Timeout pattern on task-based asynchronous method in C#
- Channels with CancellationTokenSource with timeout memory leak after dispose