-
May 21st, 2010, 05:42 AM
#1
Event handler is being called more than once???
Hi,
I am using event-delegate pattern in the project to update the UI, when some data is received on the udp port. Each tabpage has 4 buttons on click of each button a request is sent to the device(h/w), based on the response received - respective event handler will be called.
The problem is that the event handler is called twice, for the same request, which is not desired. Can someone tell me how this could be resolved???
Any help would be great
-
May 21st, 2010, 11:23 PM
#2
Re: Event handler is being called more than once???
Can you post the relevant code using code tags?
-
May 23rd, 2010, 11:22 AM
#3
Re: Event handler is being called more than once???
I agree with rohs -- need to see code for a speicfic solution. A generic (and not particulalry desireable) workaround might be:
Code:
bool hasBeenHandled = false;
private void handlerMethod(){
if(!hasBeenHandled){
//do your stuff
hasBeenHandled=true;
}else{
hasBeenHandled = false;
}
}
This will ensure that the method ignores every other time it's called.
Again, not the best workaround, but without knowing what's going on, this is a rough patch. Post your code for more detailed answer =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|