async-ctp

Cancel an async webrequest?

给你一囗甜甜゛ 提交于 2019-12-01 18:59:32
I am using the Async CTP library for Windows Phone. Does anyone know how to cancel a pending webrequest? Request = (HttpWebRequest)WebRequest.Create(url); Request.Credentials = new NetworkCredential(_settings.Username, _settings.Password); WebResponse resp; try { resp = await Request.GetResponseAsync(); } There is no cancellation token (as specified in the ASYNC Ctp tap document ). You could try calling Request.Abort() . 来源: https://stackoverflow.com/questions/8635723/cancel-an-async-webrequest

What are the major risks vs. benefits of using VS2010 Async CTP?

穿精又带淫゛_ 提交于 2019-12-01 07:28:23
问题 I'd like to use Visual Studio Async CTP (Version 3) for developing and testing in VS2010 SP1 on Windows XP SP3 mainly because my clients (as well as I) on Windows XP SP3. Ghere is a related discussion on MSDN forum: If I target .net 4.0 but run on a machine that has .net 4.5 will .net 4.0 WPF bugs still be there? Though, the NOTE ON "AS IS" LICENSE tells: While the Async CTP license does not prevent you using it at your own risk in production environments, we advise you not to. The goal of

Cancellation Token in await method

落爺英雄遲暮 提交于 2019-12-01 06:00:12
There are many reasons to put a token in the constructor of a task, mentioned here: Cancellation token in Task constructor: why? With the use of keywords, async / await, how is that working? for example my code below: public async Task MethodAsync(CancellationToken token) { await Method01Async(); await Method02Async(); } Although it is an asynchronous process. In no time I used "Task.StartNext" or "Task.Run" or "new Task". To be able to specify my cancellation token, how can I do? You aren't supposed to use the Task constructor in async methods. Usually, you just want to pass the

Can async methods have expensive code before the first 'await'?

不羁岁月 提交于 2019-12-01 03:26:34
Is it bad to have expensive code at the start of an async method, before the first await is called? Should this code be wrapped with a TaskEx.Run instead? public async Task Foo() { // Do some initial expensive stuff. // ... // First call to an async method with await. await DoSomethingAsync; } As Reed says, it really depends on the context. The code has to run at some point - but depending on the context, it may end up being run on a thread pool thread instead of some critical one. Rather than using Task.Run , I'd use TaskEx.Yield : public async Task Foo() { await TaskEx.Yield(); // Do

How to use async with Visual Studio 2010 and .NET 4.0?

半腔热情 提交于 2019-12-01 03:26:05
I want to add async support to current VS 2010 .NET 4.0 C# project I have found: Visual Studio Async CTP - http://www.microsoft.com/en-us/download/details.aspx?id=9983 Microsoft.Bcl.Async - https://nuget.org/packages/Microsoft.Bcl.Async I don't even get real difference between them. I installed both. Visual Studio Async CTP (Version 3), Microsoft.Bcl and Microsoft.Bcl.Async. (also used to run tools\portable-net40+sl4+win8+wp71\install.ps1 in Microsoft.Bcl) And still can't see any effect. Same error for public async Task<CommResponse> -> Error 37 The type or namespace name 'async' could not be

Can async methods have expensive code before the first 'await'?

寵の児 提交于 2019-11-30 23:55:56
问题 Is it bad to have expensive code at the start of an async method, before the first await is called? Should this code be wrapped with a TaskEx.Run instead? public async Task Foo() { // Do some initial expensive stuff. // ... // First call to an async method with await. await DoSomethingAsync; } 回答1: As Reed says, it really depends on the context. The code has to run at some point - but depending on the context, it may end up being run on a thread pool thread instead of some critical one.

Task chaining without TaskCompletionSource?

廉价感情. 提交于 2019-11-30 21:09:34
I'm converting some async/await code to chained tasks, so I can use it in the released framework. The await code looks like this public async Task<TraumMessage> Get() { var message = await Invoke("GET"); var memorized = await message.Memorize(); return memorized; } where Task<TraumMessage> Invoke(string verb) {} Task<TraumMessage> Memorize() {} I was hoping to chain Invoke and Memorize to return the task produced by Memorize , but that results in a Task<Task<TraumMessage> . The solution i've ended up is a TaskCompletionSource<TraumMessage> as my signal: public Task<TraumMessage> Get() { var

Does async and await increase performance of an ASP.Net application

这一生的挚爱 提交于 2019-11-30 06:01:19
问题 I recently read an article about c#-5 and new & nice asynchronous programming features . I see it works greate in windows application. The question came to me is if this feature can increase ASP.Net performance? consider this two psudo code: public T GetData() { var d = GetSomeData(); return d; } and public async T GetData2() { var d = await GetSomeData(); return d; } Has in an ASP.Net appication that two codes difference? thanks 回答1: Well for a start your second piece of code would return

Asp.NET MVC 3 project templates not showing up

早过忘川 提交于 2019-11-30 05:32:48
问题 I installed the Async CTP w/o knowing it would cause problems with Asp.NET MVC 3. So I've followed every possible uninstall instruction out there re-installed both SP1 and MVC 3. However, the MVC 3 templates does not show up in the new project dialogs. And I have ensured that target platform is .NET 4 in the dialog, so that is not the cause. Any ideas on how to make the MVC 3 templates re-appear? 回答1: Try this: Clear out the template cache located at "[ProgramFile x86]\Microsoft Visual Studio

What happens to an `awaiting` thread in C# Async CTP?

混江龙づ霸主 提交于 2019-11-29 23:32:00
I've been reading about the new async await keyword and it sounds awesome, but there is one key question I haven't been able to find the answer for in any of the intro videos I've watched so far (I also read the whitepaper a while back). Suppose I have a call to await in a nested function on the main UI thread. What happens to the thread at this point? Does control go back to the message loop and the UI thread is free to process other inputs? When the awaited task completes, does the entire stack get pushed onto a message queue, such that control will return through each of those nested