@manhng

Welcome to my blog!

Asynchronous Programming (Simple)

October 15, 2021 11:28

Asynchronous Programming (edit)

Asynchronous programming in C# | Microsoft Docs

When to Use (and Not to Use) Asynchronous Programming: 20 Pros Reveal the Best Use Cases – Stackify

Asynchronous Programming :: Eloquent JavaScript

.NET Framework

public string GetString() {
    ...
        
    var resp = response.Content
                .ReadAsStringAsync()
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
    return resp;
}

.NET Core

public async Task ReadStringAsync() {
    ...
    return await response.Content.ReadAsStringAsync();
}
public async Task ReadStringAsync() {
    ... (no await called)
    return await Task.FromResult(string.Empty);
}

Asynchronous Programming Best Practies

April 23, 2021 13:44

Asynchronous Programming (edit)

Async/Await - Best Practices in Asynchronous Programming | Microsoft Docs (HAY HAY HAY)

Best practices in .Net asynchronous programming | InfoWorld (HAY HAY HAY)

Devops best practices: How to drive agility and operational excellence | InfoWorld

AppVeyor & Azure DevOps

AppVeyor: Tích hợp liên tục cho các nhà phát triển bận rộn

AppVeyor tự động hóa việc xây dựng, thử nghiệm và triển khai các ứng dụng .NET giúp nhóm của bạn tập trung vào việc cung cấp các ứng dụng tuyệt vời.

Login - AppVeyor

Các tính năng chính:

  • Không cần thiết lập hoặc bảo trì
  • Cấu hình xây dựng thân thiện với nhà phát triển bằng UI hoặc YAML
  • Xây dựng nhanh trên phần cứng chuyên dụng với ổ SSD
  • Xây dựng nhiều chi nhánh
  • Nhân viên và hỗ trợ cộng đồng
  • Trả giá khi bạn đi

Các phần mềm tương tự AppVeyor:

GitHub - ariya/karma-appveyor: Karma AppVeyor integration demo

BenchmarkDotNet

Powerful .NET library for benchmarking

GitHub - dotnet/BenchmarkDotNet: Powerful .NET library for benchmarking

Generate PDF Files

How to Generate PDF Files in Python with Xhtml2pdf, WeasyPrint or Unoconv - Gearheart

Creating PDF Reports with Pandas, Jinja and WeasyPrint - Practical Business Python (pbpython.com)

6 Things to Do Before You Outsource Web Development - Gearheart

Azure DevOps

Dịch vụ cho các nhóm chia sẻ mã, theo dõi công việc và gửi phần mềm cho bất kỳ ngôn ngữ nào. Đó là sự bổ sung hoàn hảo cho IDE của bạn.

Công cụ triển khai phần mềm hàng đầu: 25 công cụ hữu ích để hợp lý hóa việc phân phối cài đặt phần mềm - Danh Võ (danhvo.net)

CSS

  • Typography

  • Blueprint CSS

Avoid mixing asynchronous and synchronous code

You should never have a mix of synchronous and asynchronous code. It is a bad programming practice to block on async code by making calls to Task.Wait or Task.Result. I would recommend using async code end to end – it is the safest way to avoid errors from creeping in.

You can avoid deadlocks by using .ConfigureAwait(continueOnCapturedContext: false) whenever you make a call to await. If you don't use this, the async method would block at the point where await has been called. In this case you are just informing the awaiter not to capture the current context. I would say that it is a good practice to use .ConfigureAwait(false) unless you have a specific reason to not use it.

I would discuss more on asynchronous programming in my future blog posts here. For more information on best practices in asynchronous programming, you can refer to Stephen Cleary's great article at MSDN.

Code Coverage:

Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

GitHub - FortuneN/FineCodeCoverage: Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

FineCodeCoverage 1.1.144 - AppVeyor

Best Practices:

How to use SortedDictionary, SortedList, and SortedSet in C# | InfoWorld

How to benchmark C# code using BenchmarkDotNet | InfoWorld

How to work with Quartz.Net in C# | InfoWorld

How to use Moq to ease unit testing in C# | InfoWorld

How to perform lazy initialization in C# | InfoWorld

How to work with reflection in C# | InfoWorld

How to avoid temporal coupling in C# | InfoWorld

7 best practices for remote development teams | InfoWorld

You can explore a demo ASP.NET Core application that illustrates several ways to benchmark the code. You can get the application from the ASP.NET repo on GitHub. 

How to do more in C#: 

Categories

Recent posts