The curious case of async, await, and IDisposable
Bill Blogs in C#
by
3y ago
Consider this two methods:   public Task DoWorkAsync() {     var arg1 = ComputeArg();     var arg2 = ComputeArg();     return AwaitableMethodAsync(arg1, arg2); } public async Task DoWork2Async() {     var arg1 = ComputeArg();     var arg2 = ComputeArg();     await AwaitableMethodAsync(arg1, arg2); }   Do you notice the difference? The first is a synchronous method that returns a Task. The Task may or may not have completed when the method returns. The second as an async method that returns the r ..read more
Visit website
Slides and Demos from NDC London
Bill Blogs in C#
by
3y ago
I had the pleasure of speaking at NDC London again this year. I gave two talks this year. First, a discussion of controversial C# Language design decisions. In this talk, I explained the rationale behind some of the more controversial decisions made by the C# language design team. I discussed two new features: local functions, and the extensions to the switch statement for pattern matching. The rest of the list contained overload resolution and base classes, XML literals, var and implicitly typed variables, nested scopes, and declaring base classes and interfaces on partial classes. The second ..read more
Visit website
Announcement: Effective C# 3rd Edition
Bill Blogs in C#
by
3y ago
I’m excited to announce that the 3rd edition of “Effective C#” is coming out this month. Just in time for a Christmas gift for that developer on your list. This is the first major milestone in a large project: I’m updating both “Effective C#” and “More Effective C#”. The first edition of “More Effective C#” was released in 2005, coinciding with the release of C# 3. A number of the items covered LINQ and related language features. The second edition of “Effective C#” came up a few years later with C# 4. The new areas were dynamic support, and the PLINQ libraries. Then, I waited. I did not want ..read more
Visit website
Upcoming Event announcement: NDC London
Bill Blogs in C#
by
3y ago
I’m quite thrilled to announce that I’ll be speaking at NDC London this coming January. I’ve got two talks, one very practical, and one a fun technical exploration.   First, there’s a Deep Dive into C# Pattern Matching. Pattern Matching in C# 7 will change the way you code in C#. Your gaining powerful new tools for many different idioms. In this session, I’ll explain why this feature was added. You’ll see lots of examples of different types of patterns you can work with, and we’ll discuss some of the initial guidance for using these features. Second, there’s a discussion and critique on d ..read more
Visit website
Docker Cheat Sheet
Bill Blogs in C#
by
3y ago
I’ve been working with Docker on both Windows and the Mac these past few weeks. Everything I’ve been doing is command line based. In this post, I list the commands I use most often, with the options I need the most. Disclaimer: This not meant to be a complete Docker reference. It’s a quick way to remember the commands and options I use most often. Your mileage may vary. All of these topics are covered in more depth on the Docker site. For specific .NET Content, checkout the .NET Core and .NET Framework content for running .NET applications in Docker. As you start working with Docker, you mus ..read more
Visit website
The curious case of Any() and All()
Bill Blogs in C#
by
3y ago
Last week, I posted a puzzle on twitter. Fill in the GetSpecialSequence() method such that Any() returns false, and All() returns true.  Here’s the code from the puzzle:   using static System.Console; using System.Collections.Generic; using System.Linq;   namespace AnyAndAll {     public class Program     {         public static void Main(string[] args)         {             var sequence = GetSpecialSequence();    &n ..read more
Visit website
The C# difference between "true" and "not false"
Bill Blogs in C#
by
3y ago
This is the story of a C# language specification change. The specification changed because the 1.0 version of the C# spec disagreed with itself, and one of those locations was incorrect and broke a feature.   The change is in the section on “Conditional Logic Operators”.  Version 1 of the spec states: The operation x && y corresponds to the operation x & y, except that y is evaluated only if x is true. The operation x || y corresponds to the operation x | y, except that y is evaluated only if x is false. The later versions (starting with version 3) state: The operation ..read more
Visit website
Do async lambdas return Tasks?
Bill Blogs in C#
by
3y ago
The TL;DR; version is: Sometimes. The more important question is how you ensure that you generate the method call you want. Let’s start with a bit of background. Lambda expressions do not have types. However, they can be converted into any compatible delegate type. Take these two declarations as a starting point: Action task = async () => await Task.Yield(); Func<Task> task2 = async () => await Task.Yield(); Notice that this lambda body can be assigned to either an Action or a Func<Task>. The lambda expression can represent either an async void method, or a Task returning a ..read more
Visit website
Updates from Tech O Rama
Bill Blogs in C#
by
3y ago
I had the opportunity to speak at Tech O Rama in Mechelen, Belgium last week.  It was my first trip to continental Europe. Belgium is a wonderful country, and I’m very impressed with the conference that Gill, Pieter, Kevin, and the other volunteers put together. My talks were on C# 7, and using the Roslyn APIs. Those talks were both updates form my NDC talks. The repositories contain the updated presentations and code. I also substituted for Martin Woodward, giving his talk on the .NET Foundation. And appearing in an upcoming .NET Rocks show discussing Open Source. The C# 7 story has move ..read more
Visit website
C# 7 Proposal: With-Expressions
Bill Blogs in C#
by
3y ago
//Build changes Everything I started this series after giving a presentation at NDC London on the potential features up for discussion in C# 7. That information was based on the public design discussions on GitHub. Now that //build has happened, we know a bit more about the plans. There is even a public preview of Visual Studio 15 available for download. There are two versions: a ‘classic’ installer, and a new lightweight installer that runs much more quickly but has fewer scenarios supported. I have installed both installers of Visual Studio 15 on my machine. They install side-by-side, and my ..read more
Visit website

Follow Bill Blogs in C# on FeedSpot

Continue with Google
Continue with Apple
OR