ObservableConcurrentQueue 2.0.1

dotnet add package ObservableConcurrentQueue --version 2.0.1
NuGet\Install-Package ObservableConcurrentQueue -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObservableConcurrentQueue" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObservableConcurrentQueue --version 2.0.1
#r "nuget: ObservableConcurrentQueue, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ObservableConcurrentQueue as a Cake Addin
#addin nuget:?package=ObservableConcurrentQueue&version=2.0.1

// Install ObservableConcurrentQueue as a Cake Tool
#tool nuget:?package=ObservableConcurrentQueue&version=2.0.1

ObservableConcurrentQueue

ObservableConcurrentQueue

.NET NuGet Badge

Using System.Collections.Concurrent.ConcurrentQueue with notifications

Get the latest version of source code from Github

Or get it from NUGET:

PM> Install-Package ObservableConcurrentQueue

Documentation

if you are not familiar with ConcurrentQueue, Read more about it on MSDN

Usage

Syntax

Create new instance

var observableConcurrentQueue = new ObservableConcurrentQueue();
Note about Thread Safety:

According to Mircosoft Documentation All public and protected members of ConcurrentQueue<T> are thread-safe and may be used concurrently from multiple threads. This additional Thread Safe option is just for some customization stuff.

Subscribe the Handler to the event ContentChanged

observableConcurrentQueue.ContentChanged += OnObservableConcurrentQueueContentChanged;

Option 2: Subscribe to CollectionChanged Event

observableConcurrentQueue.CollectionChanged += OnObservableConcurrentQueueCollectionChanged;

Example of handling method:

Queue Content Changed

private static void OnObservableConcurrentQueueContentChanged(
 object sender,
 NotifyConcurrentQueueChangedEventArgs args)
 {
      // Item Added
      if (args.Action == NotifyConcurrentQueueChangedAction.Enqueue)
      {
          Console.WriteLine("New Item added: {0}", args.ChangedItem);
      }
 
      // Item deleted
      if (args.Action == NotifyConcurrentQueueChangedAction.Dequeue)
      {
          Console.WriteLine("New Item deleted: {0}", args.ChangedItem);
      }
 
      // Item peeked
      if (args.Action == NotifyConcurrentQueueChangedAction.Peek)
      {
           Console.WriteLine("Item peeked: {0}", args.ChangedItem);
      }
 
      // Queue Empty
      if (args.Action == NotifyConcurrentQueueChangedAction.Empty)
      {
           Console.WriteLine("Queue is empty");
      }
 } 

Collection Changed event

private static void OnObservableConcurrentQueueCollectionChanged(
     object sender,
     NotifyCollectionChangedEventArgs args)
{
     if (args.Action == NotifyCollectionChangedAction.Add)
     {
          Console.WriteLine($"[+] Collection Changed [Add]: New Item added: {args.NewItems[0]}");
     }

     if (args.Action == NotifyCollectionChangedAction.Remove)
     {
          Console.WriteLine($"[-] Collection Changed [Remove]: New Item deleted: {args.OldItems[0]}");
     }

     if (args.Action == NotifyCollectionChangedAction.Reset)
     {
          Console.WriteLine("[ ] Collection Changed [Reset]: Queue is empty");
     }
}

Once the handler is defined, we can start adding, deleting or getting elements from the concurrentQueue, and after each operation an event will be raised and handled by the method above.

Event Args

The EventArgs object sent by the event contains 2 properties:

NotifyConcurrentQueueChangedAction Action:

  • Enqueue: If a new item has been enqueued.
  • Dequeue: an item has been dequeued.
  • Peek: an item has been peeked.
  • Empty: The last element in the queue has been dequeued and the queue is empty.

T ChangedItem:

The item which the changes applied on. can be null if the notification action is NotifyConcurrentQueueChangedAction.Empty.

Supported Frameworks

.NET Standard

netstandard1.1 netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1

.NET

net5.0 net6.0

.NET Core

netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1

.NET Framework

net40 net45 net451 net452 net46 net461 net462 net47 net471 net472 net48

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 is compatible.  netcoreapp1.1 is compatible.  netcoreapp2.0 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 is compatible.  netcoreapp3.0 is compatible.  netcoreapp3.1 is compatible. 
.NET Standard netstandard1.1 is compatible.  netstandard1.2 is compatible.  netstandard1.3 is compatible.  netstandard1.4 is compatible.  netstandard1.5 is compatible.  netstandard1.6 is compatible.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 1.0

  • .NETCoreApp 1.1

  • .NETCoreApp 2.0

    • No dependencies.
  • .NETCoreApp 2.1

    • No dependencies.
  • .NETCoreApp 2.2

    • No dependencies.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 1.1

  • .NETStandard 1.2

  • .NETStandard 1.3

  • .NETStandard 1.4

  • .NETStandard 1.5

  • .NETStandard 1.6

  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ObservableConcurrentQueue:

Package Downloads
VDG_MultiThreadsEngine

Well tested, using in production code supporting for Multi-Thread Tasks with time out and throttler.

MultiThreadsEngine

Well tested, using in production code supporting for Multi-Thread Tasks with time out and throttler.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 23,621 2/6/2022
2.0.0 420 2/6/2022
1.2.0 488 2/5/2022
1.1.0 10,257 9/20/2020
1.0.2 4,613 7/29/2018
1.0.1 1,413 7/29/2018
1.0.0 2,523 1/5/2015