c# Event移除所有绑定,注销事件绑定
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;
            }
        }
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号