CSoft.CommTask 11.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSoft.CommTask --version 11.0.0
                    
NuGet\Install-Package CSoft.CommTask -Version 11.0.0
                    
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="CSoft.CommTask" Version="11.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSoft.CommTask" Version="11.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CSoft.CommTask" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSoft.CommTask --version 11.0.0
                    
#r "nuget: CSoft.CommTask, 11.0.0"
                    
#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.
#:package CSoft.CommTask@11.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSoft.CommTask&version=11.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CSoft.CommTask&version=11.0.0
                    
Install as a Cake Tool

CSoft.CommTask

为自定义通信层提供请求队列、发送调度、响应匹配和超时管理。通过传输适配接口接入已有的串口、TCP、UDP 或测试传输。需要把物理口与分帧器组装成通信端口时,可使用 CSoft.TopPortLib。

安装

dotnet add package CSoft.CommTask --version 11.0.0

提供 .NET 8、9、10、11 专用目标,另通过 .NET Standard 2.0 兼容 .NET Framework 4.8。

选择队列

队列 传输适配接口 适用场景
CrowLayer<TReq, TRsp> ITilesLayer<TReq, TRsp> 串行处理请求,一次等待一个响应。适合设备轮询和主从协议。
PigeonLayer IPigeonTilesLayer 双工请求与主动推送。按响应类型和匹配字节关联请求,服务端还按客户端区分。
SparrowLayer ISparrowTilesLayer 多对端请求与主动推送,按客户端标识区分请求。适合 UDP 多对多通信。

Pigeon 和 Sparrow 的解析委托把传入字节转换为 ParsedResponse。响应类型和匹配字节应与发送请求时提供的匹配规则对应。

Crow 内存回环

下面的控制台示例使用传输适配器即时返回响应,可以直接运行并输出 42。

using System;
using System.Threading.Tasks;
using CommTask;
using CommTask.Interfaces;

await using var queue = new CrowLayer<int, int>(new LoopbackTiles(), timeDelayAfterSending: 0);
await queue.StartAsync();
Console.WriteLine(await queue.RequestAsync(41, timeout: 1000));

sealed class LoopbackTiles : ITilesLayer<int, int>
{
    public event Action<int> OnReceiveData = delegate { };

    public Task SendAsync(int data, int timeDelayAfterSending)
    {
        OnReceiveData(data + 1);
        return Task.Delay(timeDelayAfterSending);
    }
}

RequestAsync 发送请求并等待响应,SendAsync 仅排队发送。Crow 在底层发送和 OnSentData 回调返回后开始计算响应超时。StopAsync 会等待当前底层发送和事件回调结束,已收到的响应可以正常交付,排队和等待入队的请求以 CrowStopWorkingException 结束。关闭完成后可通过 StartAsync 启动新队列。

仓库的 TestDemo/TopPortLib.Tests/CrowLayerShutdownTests.cs 包含关闭与重启测试。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CSoft.CommTask:

Package Downloads
CSoft.TopPortLib

通信口使用类库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.3 70 11/13/2026
11.0.2 58 11/13/2026
11.0.1 84 11/12/2026
11.0.0 72 11/12/2026
10.6.2 2,040 5/28/2026
10.6.1 343 5/28/2026
10.6.0 487 5/27/2026
10.5.1 418 5/25/2026
10.5.0 433 5/25/2026

升级至 11.0.0,新增 .NET 8、9 和 11 目标,继续提供 .NET Standard 2.0 和 .NET 10。
Crow 停止时释放待发送请求及等待入队的任务,保留已经收到的响应。