可观察队列?

编程入门 行业动态 更新时间:2024-10-16 16:12:08
本文介绍了可观察队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有人编写过实现 INotifyCollectionChanged 的​​ .Net 通用队列版本,或者是否已经在 .Net 框架深处某个地方隐藏了一个?

Has anyone written a version of .Net's generic Queue that implements INotifyCollectionChanged, or is there one hidden deep in the .Net framework somewhere already?

推荐答案

快速搜索没有显示任何结果.但是接口很简单,扩展 Queue 类并添加对接口的支持几乎是微不足道的.只需重写所有方法:

A quick search didn't show any results. But the interface is simple and it would be almost trivial to extend the Queue class and add support for the interface. Just override all methods thusly:

// this isn't the best code ever; refactor as desired protected void OnCollectionChanged( NotifyCollectionChangedEventArgs ccea){ var temp = CollectionChanged; if(temp != null) temp(this, ccea); } // and later in the class public override SomeMethodThatAltersTheQueue(object something){ // record state of collection prior to change base.SomeMethodThatAltersTheQueue(something) // create NotifyCollectionChangedEventArgs with prior state and new state OnCollectionChanged(ccea); }

更多推荐

可观察队列?

本文发布于:2023-11-13 02:21:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583152.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!