✅ Sequentially Queueing and Processing Async Messages
I have a websocket connection between two applications. I need to have one of the applications process received messages sequentially (finish processing first message before starting on second message). The receiving application has a single method where all received messages are processed.
Assuming I can asynchronously collect received messages, how can I queue them for sequential processing based on the order they were received? Thank you!
5 Replies
https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentqueue-1?view=net-7.0 ConcurrentQueue is probably what you're looking for
Ooo I'll give that a try!
Thanks again @Doombox! I found these resources quite helpful on the subject:
https://dotnetpattern.com/csharp-concurrentqueue
https://github.com/YounesCheikh/ObservableConcurrentQueue
dotnetpattern.com
ConcurrentQueue in C# - Introduction and Examples
C# ConcurrentQueue is a thread-safe collection class. It is introduced in .NET 4.0 with other concurrent collection classes. Thread-safe FIFO data structure.
GitHub
GitHub - YounesCheikh/ObservableConcurrentQueue: Using System.Colle...
Using System.Collections.Concurrent.ConcurrentQueue with notifications - GitHub - YounesCheikh/ObservableConcurrentQueue: Using System.Collections.Concurrent.ConcurrentQueue with notifications
!done
what is the right way to close this thread?
/close