首页 > Windows开发 > 详细

c# Event移除所有绑定,注销事件绑定

时间:2021-08-25 08:29:57      阅读:17      评论:0      收藏:0      [点我收藏+]

public delegate void d_ReadyToPrint(byte[] bytes);
public event d_ReadyToPrint ReadyToPrint;

public void ClearAllEvent()
{
if (ReadyToPrint == null) return;
Delegate[] dels = ReadyToPrint.GetInvocationList();
foreach (Delegate del in dels)
{
object delObj = del.GetType().GetProperty("Method").GetValue(del, null);
string funcName = (string)delObj.GetType().GetProperty("Name").GetValue(delObj, null);
Console.WriteLine(funcName);
ReadyToPrint -= del as d_ReadyToPrint;
}
}

c# Event移除所有绑定,注销事件绑定

原文:https://www.cnblogs.com/xhztech/p/15182868.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!