Open utterances-bot opened 1 year ago
有没有可能把这套标准化的中继事件用自动代码生成来写?
[WeakEvent(typeof(ListBox), nameof(ListBox.SelectionChanged), typeof(SelectionChangedEventHandler))]
public partial class ListBoxWeakEventRelay
{
}
[WeakEvent(typeof(INotifyCollectionChanged), nameof(INotifyCollectionChanged.CollectionChanged), typeof(NotifyCollectionChangedEventHandler))]
public partial class INotifyCollectionChangedWeakEventRelay
{
}
.NET/C# 利用 Walterlv.WeakEvents 高性能地中转一个自定义的弱事件(可让任意 CLR 事件成为弱事件) - walterlv
弱引用是 .NET 引入的概念,可以用来协助解决内存泄漏问题。然而事件也可能带来内存泄漏问题,是否有弱事件机制可以使用呢?.NET 没有自带的弱事件机制,但其中的一个子集 WPF 带了。然而我们不是什么项目都能引用 WPF 框架类库的。网上有很多弱事件的 NuGet 包,不
https://blog.walterlv.com/post/implement-custom-dotnet-weak-event-relay.html