async-ctp

await/async vs. “classic” asynchronous (callbacks)

被刻印的时光 ゝ 提交于 2019-12-20 09:06:23
问题 So the new async CTP is very cool; it makes my life a lot easier not having to write named callback methods and makes the intent of the methods a lot clearer. Now that I've gotten to play with it a little, I'm wondering what differences there may be between the async/await and the "classic" asynchronous callback syntaxes. Here are a few questions I have in mind, but there are numerous others that I won't have thought of now and probably will later. Does one perhaps offer superior performance

await/async vs. “classic” asynchronous (callbacks)

試著忘記壹切 提交于 2019-12-20 09:05:41
问题 So the new async CTP is very cool; it makes my life a lot easier not having to write named callback methods and makes the intent of the methods a lot clearer. Now that I've gotten to play with it a little, I'm wondering what differences there may be between the async/await and the "classic" asynchronous callback syntaxes. Here are a few questions I have in mind, but there are numerous others that I won't have thought of now and probably will later. Does one perhaps offer superior performance

Cancel an async webrequest?

不羁岁月 提交于 2019-12-19 19:04:47
问题 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). 回答1: You could try calling Request.Abort() . 来源: https://stackoverflow.com/questions/8635723/cancel-an-async

Cancel an async webrequest?

≯℡__Kan透↙ 提交于 2019-12-19 19:03:35
问题 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). 回答1: You could try calling Request.Abort() . 来源: https://stackoverflow.com/questions/8635723/cancel-an-async

Cancellation Token in await method

ぐ巨炮叔叔 提交于 2019-12-19 07:45:23
问题 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? 回答1: You

Cancellation Token in await method

情到浓时终转凉″ 提交于 2019-12-19 07:45: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? 回答1: You

Using Async CTP with Portable Class Library

被刻印的时光 ゝ 提交于 2019-12-19 07:23:51
问题 I am trying to rewrite a project into a Portable Class Library. But the problem is that it is using Async CTP, and I can't compile it as a library for WP and Windows Store App. If I don't include reference AsyncCtpLibrary.dll, compiler says that The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?) If i include it, compiler still says the same errors and adds a warning: The primary reference "AsyncCtpLibrary" could not

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

爱⌒轻易说出口 提交于 2019-12-19 05:47:30
问题 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

C# async methods still hang UI

本秂侑毒 提交于 2019-12-17 19:21:35
问题 I have these two methods, that I want to run async to keep the UI responsive. However, it's still hanging the UI. Any suggestions? async void DoScrape() { var feed = new Feed(); var results = await feed.GetList(); foreach (var itemObject in results) { var item = new ListViewItem(itemObject.Title); item.SubItems.Add(itemObject.Link); item.SubItems.Add(itemObject.Description); LstResults.Items.Add(item); } } public class Feed { async public Task<List<ItemObject>> GetList() { var client = new

Why use async requests instead of using a larger threadpool?

喜你入骨 提交于 2019-12-17 10:12:31
问题 During the Techdays here in the Netherlands Steve Sanderson gave a presentation about C#5, ASP.NET MVC 4, and asynchronous Web. He explained that when requests take a long time to finish, all the threads from the threadpool become busy and new requests have to wait. The server can't handle the load and everything slows down. He then showed how the use of async webrequests improves performance because the work is then delegated to another thread and the threadpool can respond quickly to new