2012-09-26 4 views
3

가능한 중복 :
Remove handlers on disposing object개체를 삭제할 때 이벤트를 제거해야합니까?

는 동적으로 추가하고 Form에서에/Controls을 제거하는 몇 가지 코드가 있습니다. 컨트롤은 폼 소유의 컬렉션에 저장됩니다. 컨트롤을 제거하면 코드가 다음과 같이 처리되어 폐기됩니다.

if (node != null && !node.IsDisposed) 
    { 
     node.Resize -= docNode_Resize; 
     node.DocumentRefreshRequested -= docNode_DocumentRefreshRequested; 
     node.Dispose(); 
    } 

이벤트 제거 중 일부가 필요합니까? 같은 Dispose() 것 같습니다.

+1

여러 번, 여러 번, 여러 번 묻습니다. https://www.google.com/#hl=en&output=search&sclient=psy-ab&q=site:stackoverflow.com+dispose+object+remove+event+handlers&oq=site:stackoverflow.com+dispose+object+remove+event + 핸들러 & gs_l = hp.3 ... 2009.14157.0.15027.86.71.12.0.0.0.178.8365.13j58.71.0.les % 3Beqn % 2Crate_low % 3D0-035 % 2Crate_high % 3D0-035 % 2Cmin_length % 3D2 % 2Ccconf % 3D1-2 % 2Csecond_pass % 3Dfalse % 2Cnum_suggestions % 3D1 % 2Cignore_bad_origquery % 3Dtrue..0.0 ... 1c.1.S3iqf646p8Q & pbx = 1 & bav = on.2 또는 .r_gc.r_pw.r_cp.r_qf. & fp = 7e599a8195490a44 & biw = 1440 & bih = 799 –

답변

2

묻는 질문 여러 번.

아니, 당신은하지 않는 이상, 필요가 없습니다

  • 이벤트가 정적 구독됩니다
  • (메모리 소비의 측면에서 혜택을 탈퇴 개인의 expirience에서) 이벤트 및 구독의
  • 엄청난 양
관련 문제