Category: C#

Async IPC Event Aggregator (Pt-3)

Let’s evolve our IPC Event Aggregator to include asynchronous calls and bidirectional request/response into our pluggable IPC transports. This new design preserves the weak-reference handlers, remains DI-friendly, and keeps publishers decoupled from subscribers and transport mechanics. Note: This article is for educational purposes only. To recap on the previous blog posts, we’ve first created a Simple Event Aggregator in C# which used in-memory event communications for a single application. Followed by extending it in IPC Event Aggregator in C# (Part-2) to allow for inter-process communication between multiple applications. Also, Part-2 opened the door to extend the IPC transports to be…

IPC Event Aggregator in C# (Part-2)

In the previous article Simple Event Aggregator in C# we covered creating a basic “in-memory” mechanism for transferring events within a single process and memory space. Now, let’s extend it to be able to communicate between separate executables (different processes). For that we’ll need to create what known as an Inter-Process Communication (IPC) mechanism. The challenge is that separate executables are isolated from one another by the operating system. Common IPC Solutions A dedicated event aggregator across executables would essentially be building one of the following IPC mechanisms under the hood. You can use existing libraries that abstract this communication for you,…

Simple Event Aggregator in C#

In this post, I’ll go through the inner workings of Event Aggregators, what it is, how to make one, and how to use it. Consider this another brain-dump of past knowledge to assist you in learning something new, or enhancing what you’ve previously known. This article focus on a single application; in another article, we’ll cover IPC (inter-process communication) in a similar fashion. In C#, an Event Aggregator is a design pattern that facilitates loosely coupled communication between different parts of an application, particularly between components that do not have direct references to each other. It acts as a central hub…

Prism.Avalonia

Prism.Avalonia is a library that extends the Prism framework’s capabilities to Avalonia UI applications. Avalonia UI is a cross-platform .NET UI framework that enables the development of desktop applications for Windows, Linux, and macOS, and also supports mobile and web targets. Prism is a framework designed to help build loosely coupled, maintainable, and testable XAML applications by implementing design patterns such as MVVM (Model-View-ViewModel), dependency injection, commands, and an EventAggregator for messaging. Prism.Avalonia specifically adapts these core Prism functionalities to the Avalonia UI platform, allowing developers to leverage Prism’s structured approach for: To use Prism.Avalonia, both the Prism.Avalonia core package and an associated…

C# Async/Await Under the Hood

Many of us use the async await operation in C# frequently, but how often do you peek under the hood? There’s a secret sauce that a lot of developers are unaware of that occurs. We’re going to take into the inner workings and find out where those extra clock-cycles go. The extra knowledge may help you write more efficient code. Sample Code Generated IL

Prometheus .NET Serialization

If you’ve ever used Prometheus or Prometheus-Net, you may have noticed that its Gauges use a JSON’ish implementation. And by “-ish” we mean that you cannot simply apply, System.Text.Json to deserialize the line. Here I’ll show you how to work with Prometheus to assist with your unit tests (aka automated tests, integration tests, etc). In this example, we’re going to extract the “Button Click” metrics sent by the app. Prometheus is an open-source systems monitoring solution to help collect metrics and alerts in your application. https://prometheus.io/docs/introduction/overview/ Below is an exert from the packet. Notice the key areas, “button_event_gauge“, the body…

.NET and Linux Bluetooth

Ever needed to perform some Bluetooth LE operations on your Linux device, whether it’s Raspberry PI, Ubuntu, or some other distribution? Yes, me too! In this article, we’ll dive right into using the Plugin.BlueZ NuGet package and show you how to get started using it. Feel free to contribute to the open source project over at the Suess Labs GitHub page, https://github.com/SuessLabs/Plugin.BlueZ. UPDATE! We are migrating towards the next generation package, Linux.Bluetooth NuGet package!The GA functionality is the same and future enhancements are coming soon, such as Battery monitoring. In this article, we’ll perform a simple Scanning for Devices based…

Visual Studio Linux Debugger

The VS Linux Debugger is an open-source tool created to assist with remotely deploying and debugging your Linux applications from Visual Studio 2022. Check it out on the Microsoft Marketplace or GitHub. To get started using it today it’s as easy as 1-2-3.. or perhaps, 2-3 Overview Before getting started, it is recommended to ensure your system has the latest updates. These steps have been tested against Ubuntu 20.04 LTE and 22.04 LTE. Though this project supports everywhere that .NET (Core) is supported, this section outlines steps for Ubuntu 22.04 LTE. It’s recommended to use the official Microsoft Install .NET…

C# 9.0 Null Checking

C# 9.0 added a lot of new features and enhanced others. Here we’re covering Pattern Matching, more specifically is null and is not null.  Beginning with C# 7.0, the “is” operator was added to match an expression against a pattern, and with C# 9.0 the negation pattern was added to do a non-null check. Overview So why not just use “==” or “!=” operators? When you override the operators, your traditional null checks can behave differently. This is why it can be safer for you to use the newer pattern matching. The addition of null checking using, “is null“, though…