Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要限制使用事件聚合器引发的事件的订阅数量,我该如何实现?
您可以检查您的活动InvocationList.Count的add方法。
InvocationList.Count
add
像这样的东西:
private EventHandler MyEventDel; public event EventHandler ExplicitEvent { add { if (MyEventDel.GetInvocationList().Count() < 10) { MyEventDel+= value; } } remove { MyEventDel-= value; } }