Click here to Skip to main content
15,920,704 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Probably A stupid question but I think I better check with the experts :-)

In the past I have initialized/ declared delegates in a separate module making them accessible throughout the whole solution


VB
Delegate Delegate_NO_parameter()



Then, I have been using this same delegate in numerous places in my code (different modules / forms)

Sub 1 ()
   Dim d As New Delegate_NO_parameter(AddressOf X) 
   Me.Invoke(d)
End sub

Sub 2 ()
   Dim d As New Delegate_NO_parameter(AddressOf Y) 
   Me.Invoke(d)
End sub



Now I know this might not be the proper way of doing so but so fare I've never had an issue with it - until now ...

Is it possible that by doing so, the callback's could get cross referenced = instead of calling Sub X it might call Sub Y if both get invoked at the "same" Time
I don't think it should - but in my code I was able to fix an issue that has been bugging me for days by just "moving" similar callbacks around a bit ???
Posted

 
Share this answer
 
I messed up -a timer_tick in my worker thread was messing with a global variable
= moving code around just changed the timing = resulting in inconstant results

- I'll keep using delegates as I have in the past :-)

Georg
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jun-13 15:41pm    
Aha, very nice. Not only you post this non-answer here, you even self-accepted it formally. Trying to cheat?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900