Skip to content

Instantly share code, notes, and snippets.

View SaifAqqad's full-sized avatar

Saif Alaqqad SaifAqqad

View GitHub Profile

The difference between ExecutionContext and SynchronizationContext

ExecutionContext is a state bag that captures and stores ambient state (near-by variables, other data) from the current thread and offers a way to run delegates with a specific stored ExecutionContext as the ambient state, even if we're on a different thread.

When using ExecutionContext, we're capturing the ambient state from the invoking thread and then restoring that state on the other thread when it's invoking a task completion or some other delegate


SynchronizationContext is just an abstraction over a method of invoking delegates that's specific to a given environment (like Control.BeginInvoke() for WPF or Dispatcher.BeginInvoke() for winforms)

ex: Both WPF and windows forms offer a custom SynchronizationContext that invokes delegates on the UI Thread, so instead of using the API thats specific to that environment, we use the abstraction (SynchronizationContext) to make our components framework-agnosti

using System.Text.Json;
using System.Text.Json.Nodes;
using PropertyDiff = (string Path, object? ExpectedValue, object? ActualValue);
namespace Tests;
[ShouldlyMethods]
public static class ShouldlyJsonExtensions
{
public static void ShouldBeEquivalentTo(this JsonNode actual, JsonNode expected, string? customMessage = null)
@SaifAqqad
SaifAqqad / AuraSync.ahk
Created May 20, 2023 17:08
Asus Aura Sync COM API wrapper
#Requires AutoHotkey v1.1.35+
class AuraSync {
static CLSID := "aura.sdk.1"
__New(){
this.sdk := ComObjCreate(AuraSync.CLSID)
this.isControlled := false
this.devices := []
@SaifAqqad
SaifAqqad / Main.java
Last active May 2, 2022 05:58
Mustafa's parse script
package main;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.regex.Matcher;
@SaifAqqad
SaifAqqad / svg2ico.sh
Last active March 9, 2024 18:06 — forked from azam/svg2ico.sh
Convert SVG to ICO using ImageMagick, with transparent background and multi-size icons
magick convert -density 384 -background transparent -fill "#FFFFFF" -colorize 100 icon.svg -define icon:auto-resize -colors 256 icon.ico
general.smoothScroll.currentVelocityWeighting: 0
general.smoothScroll.mouseWheel.durationMaxMS: 150
general.smoothScroll.stopDecelerationWeighting; 0.82
mousewheel.min_line_scroll_amount: 25