Showing results for seteplia - Developer Support

Oct 1, 2018
2
0

The danger of TaskCompletionSource class

Sergey Tepliakov
Sergey Tepliakov

... when used with async/await. TaskCompletionSource class is a very useful facility if you want to control the lifetime of a task manually. I share a canonical example when TaskCompletionSource is used for converting the event-based asynchronous code to the Task-based pattern.

seteplia
Sep 5, 2018
0
0

Combining iterator blocks and async methods in C#

Sergey Tepliakov
Sergey Tepliakov

One of the best traits of a well-designed system is composability. Large systems are complex and hierarchical and one of the best ways to fight accidental complexity is to compose a system from smaller components. You write and test each component independently then you glue them together to achieve a higher-level behavior. Programming languages...

seteplia
Jul 17, 2018
2
1

Performance implications of default struct equality in C#

Sergey Tepliakov
Sergey Tepliakov

If you're familiar with C#, then you most likely heard that you should always override and for custom structs for performance reasons. To better understand the importance and the rationale behind this advice we're going to look at the default behavior to see why and where the performance hit comes from. Then we'll look at a performance bug that o...

seteplia
Jun 12, 2018
2
0

Dissecting new generic constraints in C# 7.3

Sergey Tepliakov
Sergey Tepliakov

During the last Build conference, Microsoft has announced the next version of Visual Studio with C# 7.3 support. This is yet another minor language update with some quite interesting features. The main change was related to generics, starting from C# 7.3 there 3 more constraints: , and . The constraint The constraint on generic type enforces ...

seteplia
May 3, 2018
0
2

Avoiding struct and readonly reference performance pitfalls with ErrorProne.NET

Sergey Tepliakov
Sergey Tepliakov

As you may know from my previous posts "The 'in'-modifier and the readonly structs in C#" and "Performance traps of ref locals and ref returns in C#", structs are trickier then you might think. Mutability aside, the behavior of readonly and non-readonly structs in "readonly" contexts is very different. Structs are meant for high-performance scen...

seteplia
Apr 11, 2018
0
1

Performance traps of ref locals and ref returns in C#

Sergey Tepliakov
Sergey Tepliakov

The C# language from the very first version supported passing arguments by value or by reference. But before C# 7 the C# compiler supported only one way of returning a value from a method (or a property) - returning by value. This has been changed in C# 7 with two new features: ref returns and ref locals. But unlike other features that were rece...

seteplia
Mar 7, 2018
1
4

The ‘in’-modifier and the readonly structs in C#

Sergey Tepliakov
Sergey Tepliakov

C# 7.2 got two very important features for high-performance scenarios -- the readonly structs and the parameters. But to understand why this additions are so important and how they're related to each other we should look back in history. As you probably know, the .NET ecosystem has two family of types -- the value types (a.k.a. structs) and the...

seteplia
Feb 14, 2018
0
1

One user scenario to rule them all

Sergey Tepliakov
Sergey Tepliakov

The async series Almost every non-trivial behavior of the async methods in C# can be explained based on one user scenario: migration of the existing synchronous code to asynchronous should be as simple as possible. You should be able to add keyword before a method's return type, add suffix to its name, add keyword here and t...

seteplia
Jan 25, 2018
3
0

The performance characteristics of async methods in C#

Sergey Tepliakov
Sergey Tepliakov

The async series In the last two blog posts we've covered the internals of async methods in C# and then we looked at the extensibility points the C# compiler provides to adjust the behavior of async methods. Today we're going to explore the performance characteristics of async methods. As you should already know from the fir...

seteplia