Skip to content

Instantly share code, notes, and snippets.

View fsmaiorano's full-sized avatar
:shipit:
while(!(success = try()))

Fábio Maiorano fsmaiorano

:shipit:
while(!(success = try()))
View GitHub Profile
@fsmaiorano
fsmaiorano / sample-using-iprogress.cs
Created March 31, 2025 16:58 — forked from HamidMolareza/sample-using-iprogress.cs
Sample for using `IProgress` in long-running tasks in C#
/*
`IProgress<T>` in C# is an interface provided by the .NET Framework to report progress in an asynchronous operation. It allows a producer (usually a background task) to communicate progress updates to a consumer (often the UI thread or another monitoring task).
This setup ensures that the progress reporting mechanism is thread-safe and that the consumer of the progress updates can safely update the UI or other state based on the progress.
*/
// var progress = new Progress<(long count, List<string> files)>(ReportProgress);
var progress = new Progress<(long count, List<string> files)>();
progress.ProgressChanged += (_, data) => {
Console.WriteLine($"{data.count} files read. Last file: {data.files.Last()}");
@fsmaiorano
fsmaiorano / master.yml
Created January 13, 2024 22:40 — forked from Carl-Hugo/master.yml
GitHub Action: Deploy Blazor WASM to GitHub Pages
name: Deploy Blazor WASM to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps: