How to handle cancellation of x number of running background tasks.
Source: Cancellation in Managed Threads | Microsoft Docs
Code examples: https://docs.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads#code-example
My bookmarks and blogposts regarding Software Development in .NET, C#, Angular, JavaScript, CSS, Html
How to handle cancellation of x number of running background tasks.
Source: Cancellation in Managed Threads | Microsoft Docs
Code examples: https://docs.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads#code-example
SharpLab is a .NET code playground that shows intermediate steps and results of code compilation. Some language features are thin wrappers on top of other features — e.g.
using()
becomestry/finally
. SharpLab allows you to see the code as compiler sees it, and get a better understanding of .NET languages.Recent versions include experimental support for running code, with some limitations.
Online tool: SharpLab
Sometimes you need to implement some sort of retry logic if an error occurs in a c# program.
Existing libraries for retry and fault handling:
Polly
http://www.thepollyproject.org/
CircuitBreaker.Net
https://github.com/alexandrnikitin/CircuitBreaker.Net
Read more about the related Circuit Breaker pattern:
CircuitBreaker
http://martinfowler.com/bliki/CircuitBreaker.html
Circuit Breaker Pattern
https://msdn.microsoft.com/en-us/library/dn589784.aspx
Error handling and policies in general:
https://en.wikipedia.org/wiki/Exception_handling#Restarts_separate_mechanism_from_policy
https://docs.microsoft.com/en-us/dotnet/standard/exceptions/
https://stackify.com/csharp-exception-handling-best-practices/
In general these interfaces and methods are good to implement when working with comparing objects of the same type in C#:
Interfaces:
System.IEquatable<T> – strongly typed implementation
IComparable<T> – strongly typed implementation
Override methods:
An override of Object.Equals(Object).
An override of Object.GetHashCode().
An override of Object.ToString() is usually a good idea.
Operator overloads for operator == and operator !=.
General rule of GetHashCode():
If two objects is equal then their hashvalues should be the same.
E.g.:
If Equals == true then
x.GetHashCode() == y.GetHashCode()
GetHashCode() is frequently used by collections like Dictionary<Key, Value> and HashSet<T>
Links:
Guidelines for Overloading Equals() and Operator == (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/ms173147.aspx
Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.
Active Directory security groups are used to grant users’ permissions to various domain services and resources. Therefore, to understand what permissions are assigned to a specific user in the AD domain, it is enough to look at the groups in which the user account is a member.
I’ve long blogged about my love of setting up a nice terminal, getting the prompt just right, setting my colors, fonts, glyphs, and more. Here’s some of my posts.
…I want to take a moment to update my pretty prompt post with a little more detail and a more complex PowerShell $PROFILE, due to some changes in Oh My Posh, PowerShell, and the Windows Terminal. I doubt that this post is perfect and I’m sure there’s stuff here that is a little extra. But I like it, and this post will serve as my “setting up a new machine” post until I get around to writing a script to do all this for me in one line.
I love my prompt.
Pre made script to make it look like Scott Hanselmans example prompt:
https://github.com/springcomp/my-box
Source: My Ultimate PowerShell prompt with Oh My Posh and the Windows Terminal – Scott Hanselman’s Blog
You can add an EditorConfig file to your project or codebase to enforce consistent coding styles for everyone that works in the codebase. EditorConfig settings take precedence over global Visual Studio text editor settings. This means that you can tailor each codebase to use text editor settings that are specific to that project. You can still set your own personal editor preferences in the Visual Studio Options dialog box. Those settings apply whenever you’re working in a codebase without an .editorconfig file, or when the .editorconfig file doesn’t override a particular setting. An example of such a preference is indent style—tabs or spaces.
Source: EditorConfig settings – Visual Studio (Windows) | Microsoft Docs