增加本地Cv2.ImShow播放的动态增加、移除的支持

This commit is contained in:
2025-12-26 17:28:07 +08:00
parent 83ad6221a4
commit e98059fd30
5 changed files with 305 additions and 185 deletions

View File

@@ -177,4 +177,25 @@ public static class GlobalStreamDispatcher
}
#endregion
#region Unsubscribe
/// <summary>
/// [新增重载] 强制取消订阅:直接移除指定 AppId 的整个路由项
/// 用途:当业务模块(如播放窗口)销毁时,彻底切断该 AppId 的数据流
/// </summary>
/// <param name="appId">业务唯一标识</param>
public static void Unsubscribe(string appId)
{
if (string.IsNullOrWhiteSpace(appId)) return;
// 直接从字典中移除 Key这将丢弃该 Key 下挂载的所有委托链
// TryRemove 是原子的、线程安全的
if (_routingTable.TryRemove(appId, out _))
{
Console.WriteLine($"[Dispatcher] 已强制移除 AppId [{appId}] 的所有订阅路由");
}
}
#endregion
}