Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何移除usercontrol中的(全局事件)处理程序?_C#_Vb.net_Events - Fatal编程技术网

C# 如何移除usercontrol中的(全局事件)处理程序?

C# 如何移除usercontrol中的(全局事件)处理程序?,c#,vb.net,events,C#,Vb.net,Events,(使用vb.net) 嗨 在课堂上,我有一个公开的共享事件 在我的表单中,我有一个usercontrol,我将其“AddHandler”添加到共享事件中。但是为了避免内存泄漏(因为只要应用程序运行,共享事件就不会被处理),我如何告诉我的usercontrol RemoveHandler 我尝试使用“Disposed”事件,但它并不总是像usercontrol那样立即被释放。我想在父窗体关闭后立即移除Handler 最佳做法是什么?EventHandlerList可能是您所需要的-我使用它在其他一

(使用vb.net)

在课堂上,我有一个公开的共享事件

在我的表单中,我有一个usercontrol,我将其“AddHandler”添加到共享事件中。但是为了避免内存泄漏(因为只要应用程序运行,共享事件就不会被处理),我如何告诉我的usercontrol RemoveHandler

我尝试使用“Disposed”事件,但它并不总是像usercontrol那样立即被释放。我想在父窗体关闭后立即移除Handler


最佳做法是什么?

EventHandlerList可能是您所需要的-我使用它在其他一些控件更新后从按钮中删除单击事件

在c#
MyEvent-=MyEvent\u处理程序中