c#-5.0

Where can I find the C# 5 language specification?

纵然是瞬间 提交于 2019-12-17 17:48:06
问题 C# 5.0 is out now since August 2012. Where can I find the specification? They've stopped doing ECMA specs, but how about MSDN? 回答1: It was originally unavailable online but since June 2013 it is available for download from Microsoft. 回答2: If you have Visual Studio 2012 installed, you will find specification somewhere there: c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\Specifications\1033\CSharp Language Specification.docx similar with VS2013: c:\Program Files (x86)\Microsoft Visual

How does C# 5.0's async-await feature differ from the TPL?

北慕城南 提交于 2019-12-17 17:25:35
问题 I don't see the different between C#'s (and VB's) new async features, and .NET 4.0's Task Parallel Library. Take, for example, Eric Lippert's code from here: async void ArchiveDocuments(List<Url> urls) { Task archive = null; for(int i = 0; i < urls.Count; ++i) { var document = await FetchAsync(urls[i]); if (archive != null) await archive; archive = ArchiveAsync(document); } } It seems that the await keyword is serving two different purposes. The first occurrence ( FetchAsync ) seems to mean,

Using async without await in C#?

强颜欢笑 提交于 2019-12-17 15:39:39
问题 Consider Using async without await. think that maybe you misunderstand what async does. The warning is exactly right: if you mark your method async but don't use await anywhere, then your method won't be asynchronous. If you call it, all the code inside the method will execute synchronously. I want write a method that should run async but don't need use await.for example when use a thread public async Task PushCallAsync(CallNotificationInfo callNotificationInfo) { Logger.LogInfo("Pushing new

Task.Yield - real usages?

六月ゝ 毕业季﹏ 提交于 2019-12-17 09:19:09
问题 I've been reading about Task.Yield , And as a Javascript developer I can tell that's it's job is exactly the same as setTimeout(function (){...},0); in terms of letting the main single thread deal with other stuff aka : "don't take all the power , release from time time - so others would have some too..." In js it's working particular in long loops. ( don't make the browser freeze... ) But I saw this example here : public static async Task < int > FindSeriesSum(int i1) { int sum = 0; for (int

What's the new C# await feature do? [closed]

五迷三道 提交于 2019-12-17 03:27:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Can anyone explain what the await function does? 回答1: They just talked about this at PDC yesterday! Await is used in conjunction with Tasks (parallel programming) in .NET. It's a keyword being introduced in the next version of .NET. It more or less lets you "pause" the execution

What's the new C# await feature do? [closed]

扶醉桌前 提交于 2019-12-17 03:26:50
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Can anyone explain what the await function does? 回答1: They just talked about this at PDC yesterday! Await is used in conjunction with Tasks (parallel programming) in .NET. It's a keyword being introduced in the next version of .NET. It more or less lets you "pause" the execution

Using async-await on .net 4

梦想的初衷 提交于 2019-12-16 20:12:14
问题 I'm currently starting to create an application that would profit a lot from C# 5's async-await feature. But I'm not sure which version of VS and of the async runtime to use. Looking at OS popularity charts, I'll need to support Windows XP for another three years or so. It looks like .net 4.5 runs only on newer versions of Windows, so I need to target .net 4.0. The development machines use Windows 7, so using a newer version of VS is not a problem. Now I need to first choose a compiler for

Writinging directly to filesystem

点点圈 提交于 2019-12-14 04:14:30
问题 I want to directly writing to file system and not every line to a string, because that is much more time consuming. I try it like this: static void Main(string[] args) { string path = @"C:\BankNumber"; var bans = BankAcoutNumbers.BANS; const int MAX_FILES = 80; const int BANS_PER_FILE = 8181 / 80; int bansCounter = 0; var part = new List<int>(); var maxNumberOfFiles = 10; Stopwatch timer = new Stopwatch(); var fileCounter = 0; if (!Directory.Exists(path)) { DirectoryInfo di = Directory

Is it possible to use Task<bool> in if conditions?

丶灬走出姿态 提交于 2019-12-13 12:53:42
问题 In Windows Phone 8 I have method public async Task<bool> authentication() . The return type of the function is bool but when I tried to use its returned value in a if condition error says can not convert Task<bool> to bool . public async Task<bool> authentication() { var pairs = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string> ("user", _username), new KeyValuePair<string, string> ("password", _password) }; var serverData = serverConnection.connect("login.php", pairs);

Default TaskCreationOptions in Task.Run

老子叫甜甜 提交于 2019-12-13 12:05:04
问题 Why the default value for CreationOptions of a Task created using Task.Run is DenyChildAttach rather than None ? Has it anything to do with making work with the new async and await in C# 5.0 simpler (by preventing you from escaping current scheduler of current context I guess)? 回答1: Stephen Toub explains this well in his blog post on the subject. Parent and child tasks are somewhat common when using Task s in a parallel fashion. Note that when a parent Task has a child, the parent's