no dogma blog
no dogma blog
Blog Posts
Podcast
Web API Lambda Course
Polly Course
Photos
Contact
Support this Site
About
RSS
Light
Dark
Automatic
Asynchronous
Putting Lazy Tasks in a Cache, and Computing Only Once, When First Requested
This is an update to an earlier post on caching Tasks and only executing them when first accessed. This version uses Lazy<Task
> to hold the Task.
Sep 12, 2025
#
Cache
,
Task
,
MemoryCache
,
Async
,
Asynchronous
,
WebApi
,
Lazy
Batch Consume with Kafka and .NET
By default, the Confluent Kafka client consumes one message at time, but with a bit of work it can consume batches of messages.
Apr 17, 2025
#
Confluent
,
Kafka
,
dotNet
,
Batch
,
Async
,
Asynchronous
Putting Tasks in a Cache, and Computing Only Once, When First Requested
Caches are usually used to store concrete values, but with C# you can store tasks for work you want to perform only once, at the time the key is first requested from the cache.
Mar 19, 2025
#
Cache
,
Task
,
MemoryCache
,
Async
,
Asynchronous
,
WebApi
Create a Task and Start it Later
I usually want to run a task immediately, but there are times when I want to create a task, but not start it until later. This post will show you how to do defer execution of a task.
Mar 14, 2025
#
C#
,
dotNet
,
Task
,
Async
,
Asynchronous
Using the Confluent Kafka Consumer in a Non-Blocking Way in .NET and C#
The Consume method of the Kafka Confluent library for C# is synchronous, this post shows you how to use it in a non-blocking way.
Nov 17, 2024
#
Confluent
,
Kafka
,
Async
,
Asynchronous
,
Sync
,
Synchronous
,
BackgroundService
Making a Non Blocking Synchronous Call Inside a Background Service
This post shows you how to use a synchronous call in a background service without blocking the application or other background services.
Nov 7, 2024
#
C#
,
HostedService
,
BackgroundService
,
Async
,
Asynchronous
,
Sync
,
Synchronous
Throw ThrowIfCancellationRequested in a Method that Returns a Value when Using a Cancellation Token
When sending a cancellation request to a method that returns a value, you must return a value or throw an exception. Here is how to throw the exception.
Jan 3, 2024
#
C#
,
dotNet
,
Async
,
Asynchronous
,
CancellationToken
Simple Cancellation Token Example
Here is an example of using a cancellation token to stop the execution of a method.
Dec 28, 2023
#
C#
,
dotNet
,
Async
,
Asynchronous
,
CancellationToken
Priority Queues and Async Tasks
Priority queues are new to .NET 6. Here is a simple example using them to “schedule” async tasks.
Nov 24, 2021
#
dotNet
,
C#
,
Async
,
Asynchronous
,
Priority Queue
Cite
×