async-ctp

Is this ok to derive from TPL Task to return more details from method?

旧时模样 提交于 2019-11-29 17:23:27
问题 My original method looks like: string DoSomeWork(); Method DoSomeWork starts some work on other thread and returns execution ID (just random string). Later on I can query results by given execution ID. Main point is to make execution ID available before job will complete. Now I want to change signature to return Task, so user can wait if he want to. Task DoSomeWork(); At the same time I still need to return execution ID (for tracing purposes for example) and I see few options. First if out

Asynchronous Programming with Async and Await

妖精的绣舞 提交于 2019-11-29 09:47:03
I'm walking through this tutorial on how to program asynchronously in c# and have come across an error I'm not sure how to resolve. Here's the link: http://msdn.microsoft.com/en-us/library/hh191443.aspx and the error is: Cannot find all types required by the 'async' modifier. Are you targeting the wrong framework version, or missing a reference to an assembly? I am targeting the .NET 4.0 framework and am unsure as to any additional assemblies required. Here is the code: public async Task<string> AccessTheWebAsync(Class1 class1, Class2 class2) { // GetStringAsync returns a Task<string>. That

How to better understand the code/statements from “Async - Handling multiple Exceptions” article?

不羁岁月 提交于 2019-11-29 08:24:58
Running the following C# console app class Program { static void Main(string[] args) { Tst(); Console.ReadLine(); } async static Task Tst() { try { await Task.Factory.StartNew (() => { Task.Factory.StartNew (() => { throw new NullReferenceException(); } , TaskCreationOptions.AttachedToParent ); Task.Factory.StartNew ( () => { throw new ArgumentException(); } ,TaskCreationOptions.AttachedToParent ); } ); } catch (AggregateException ex) { // this catch will never be target Console.WriteLine("** {0} **", ex.GetType().Name); //****** Update1 - Start of Added code foreach (var exc in ex.Flatten()

Async CTP not working in VS 2010 SP1?

别来无恙 提交于 2019-11-29 07:57:27
I downloaded Async CTP and installed it on my development machine, which has both VS 2010 and VS 2012. The installation seemed to have completed successfully (no errors). I created a brand new WinForms project (language: VB.NET), and decorated a Form_Load with Async . Problem is that Async keyword is not recognized. Did anyone manage to make it work and how? Doing the same in VS 2012, targeting .NET framework 4.5 works. Note: I don't need any Silverlight , Windows Phone or even Web at this time. As suggested by @Ramhound, I uninstalled everything related to VS 2012 and 2010, then installed

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

ぐ巨炮叔叔 提交于 2019-11-28 20:53:04
问题 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

Proper way to use Async with VS 2010 now that VS 2012 is released?

允我心安 提交于 2019-11-28 13:22:52
Due to work restrictions, I need to continue using Visual Studio 2010 for the immediate future. At the same time, I have been learning about Async in my personal coding. Is the latest Async CTP fully consistent with the Async language features of C# 5.0? And is installing the Async CTP the correct way to use Async with VS2010? The Async CTP is the only way to use async in Visual Studio 2010. However, it is not the async that made it into .NET 4.5 / Visual Studio 2012, several bugs in the CTP have been fixed in the final release. You will not get these bug fixes in Visual Studio 2010, according

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

我是研究僧i 提交于 2019-11-28 13:19:22
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 Well for a start your second piece of code would return Task<T> rather than T . The ultimate answer is "it depends". If your page needs to access multiple data

C# async methods still hang UI

夙愿已清 提交于 2019-11-28 10:08:37
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 WebClient(); string content = await client.DownloadStringTaskAsync(new Uri("anyUrl")); var lstItemObjects

Asynchronous Programming with Async and Await

蹲街弑〆低调 提交于 2019-11-28 03:28:14
问题 I'm walking through this tutorial on how to program asynchronously in c# and have come across an error I'm not sure how to resolve. Here's the link: http://msdn.microsoft.com/en-us/library/hh191443.aspx and the error is: Cannot find all types required by the 'async' modifier. Are you targeting the wrong framework version, or missing a reference to an assembly? I am targeting the .NET 4.0 framework and am unsure as to any additional assemblies required. Here is the code: public async Task

Async CTP not working in VS 2010 SP1?

对着背影说爱祢 提交于 2019-11-28 01:26:26
问题 I downloaded Async CTP and installed it on my development machine, which has both VS 2010 and VS 2012. The installation seemed to have completed successfully (no errors). I created a brand new WinForms project (language: VB.NET), and decorated a Form_Load with Async . Problem is that Async keyword is not recognized. Did anyone manage to make it work and how? Doing the same in VS 2012, targeting .NET framework 4.5 works. Note: I don't need any Silverlight , Windows Phone or even Web at this