Async programming

 Async Programming

Obviously only do these in methods that are marked async.

1) Instead of .ToList() think about .ToListAsync(cancelToken).Result;  This does not apply to IEnumerable that does not have an ToListAsync().  IQueryable does have it. 

2) Instead of .FirstOrDefault(), think about .FirstOrDefaultAsync(cancelToken).Result;


Love this article:

https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/


This is ok:

https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-scenarios

Comments

Popular posts from this blog

Upgrading to .NET8 from desktop versions 4.8.X

JSON Web Tokens

GHL > Set website so shorter URL address