[dotnet] [bidi] Use System.Threading.Channels dependency for events dispatching#17004
[dotnet] [bidi] Use System.Threading.Channels dependency for events dispatching#17004nvborisenko merged 7 commits intoSeleniumHQ:trunkfrom
System.Threading.Channels dependency for events dispatching#17004Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
User description
This pull request updates the event processing mechanism in the BiDi
Brokerclass to useSystem.Threading.Channelsinstead ofBlockingCollection, improving async event handling.🔧 Implementation Notes
It also adds
System.Threading.Channelsas a dependency across the build system, project files, and NuGet specifications for all relevant target frameworks.🔄 Types of changes
PR Type
Enhancement
Description
Replace
BlockingCollectionwithSystem.Threading.Channelsfor async event dispatchingImplement unbounded channel with single reader/writer optimization
Add
System.Threading.Channelsdependency across build systemUpdate NuGet specifications and project files for all frameworks
Diagram Walkthrough
File Walkthrough
Broker.cs
Migrate event queue to System.Threading.Channelsdotnet/src/webdriver/BiDi/Broker.cs
BlockingCollection<(string Method, EventArgs Params)>withChannel<(string Method, EventArgs Params)>using unbounded channelwith single reader/writer options
ProcessEventsAwaiterAsync()to use channel reader withWaitToReadAsync()andTryRead()instead ofGetConsumingEnumerable()_pendingEvents.Add()to_pendingEvents.Writer.TryWrite()_pendingEvents.CompleteAdding()to_pendingEvents.Writer.Complete()BUILD.bazel
Add System.Threading.Channels to Bazel dependenciesdotnet/src/webdriver/BUILD.bazel
System.Threading.ChannelsNuGet package dependency towebdriver-net462 target
System.Threading.ChannelsNuGet package dependency towebdriver-netstandard2.0 target
System.Threading.ChannelsNuGet package dependency towebdriver-net462-strongnamed target
System.Threading.ChannelsNuGet package dependency towebdriver-netstandard2.0-strongnamed target
Selenium.WebDriver.nuspec
Add System.Threading.Channels to NuSpec dependenciesdotnet/src/webdriver/Selenium.WebDriver.nuspec
System.Threading.Channelsversion 8.0.0 dependency for net462target framework
System.Threading.Channelsversion 8.0.0 dependency fornetstandard2.0 target framework
Selenium.WebDriver.csproj
Add System.Threading.Channels to project filedotnet/src/webdriver/Selenium.WebDriver.csproj
System.Threading.Channelsversion 8.0.0 PackageReference fornet462 and netstandard2.0 target frameworks
Selenium.WebDriver.StrongNamed.nuspec
Add System.Threading.Channels to StrongNamed NuSpecdotnet/src/webdriver/Selenium.WebDriver.StrongNamed.nuspec
System.Threading.Channelsversion 8.0.0 dependency for net462target framework
System.Threading.Channelsversion 8.0.0 dependency fornetstandard2.0 target framework