473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Re: what is wrong with this removehandler..?

Hi, I think I understand why it behaves how it behaves.
A new feature of VB9 allows you to AddHandler for methods with slightly
different signatures than signature of event is. However as I understand it
some hidden routing method/delegate (which routes event to method with
different signature) is created in compile time. And when you uses
RemoveHandler another one is created which results to RemoveHandler removing
handler which had been never attached. So, nothing happens and handler
attached via AddHanlder is still attached.
There are two ways how to prevent this behavior:
1) Is prior VB9 - ensure that method (handler) as EXACTLY same signature as
event (event delegate)
2) Add handler is some way like this
Dim HadlerDelegate = AddressOf MyMethod
AddHandler TheObject.Event, HandlerDelegate
then store HandlerDelegate somewhere and use it with RemoveHandler.
Jun 27 '08 #1
0 635

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: teo | last post by:
Hallo, I have used many time the AddHandler method (becuse I'm buildin an array of controls). Now I 'd like to know if I have to use the RemoveHandler method. In fact I use the array of...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
5
by: VJ | last post by:
Here is snippet of my problem IF Condition1 then RemoveHandler lblCntrl.Click, AddressOf lbl_ShowItem AddHandler lblCntrl.Click, AddressOf lbl_ShowMaker2 elseif Condition2 then AddHandler...
5
by: Just Me | last post by:
Given a button name Btn_5 and Index=5 I want to do something like dim zz as string = Btn_??Index??.Text or given an array of buttons, do:
3
by: hartley_aaron | last post by:
Hi, I was trying to store the address of the my current handler for a particular event so as to simplify using AddHandler and RemoveHandler throughout my code. However, I cannot seem to get any...
13
by: dbuchanan | last post by:
This code resets a form with two cbo's (comboBoxes) and one datagrid. The first cbo (cboSelection) selects a main table and filters the second cbo. The second cbo (cboView) selects the secondary...
3
by: ken | last post by:
Hello, I can't figure out how to solve this problem. I modified the timer example given in the help section. It increments a count every 3 millisecond in order to simulate a tank being filled with...
12
by: Tom | last post by:
I use dynamically created controls all the time. I.E. I create the control in code then use AddHandler to add the necessary delegates for processing (like Click, etc). Does one have to call...
3
by: Mike | last post by:
public class Broadcaster: MarshalByRefObject, IBroadcaster { public event General.MessageArrivedHandler MessageArrived; public void BroadcastMessage(string msg) { Console.WriteLine("Will...
0
by: =?Utf-8?B?xJBvbm55?= | last post by:
Hi, I think I understand why it behaves how it behaves. A new feature of VB9 allows you to AddHandler for methods with slightly different signatures than signature of event is. However as I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.