I am currently trying to integrate threading into one method of my application and am getting this error when it's trying to set the text of the component. This is because you cannot change anything to the UI from another thread other than the original so I must use a delegate to have the method finish on the original thread before going on.(I think, if i understand this correctly)
My issue I'm having is that when I try to implement my delegate I'm getting an error
method = property evaluation failed
this also freezes my debugger and forces me to close the application. Am I declaring the delegate incorrectly? The signature for the method is the same.
Public Delegate Sub testControlToDisplay(ByVal sControlName As String, ByVal sUIName As String, ByRef IsEnabled As Boolean, ByRef IsActive As Boolean, ByVal frmctrl As String) 'Declared globally Dim delTest As testControlToDisplay 'Declared in display method delTest = New testControlToDisplay(AddressOf getControlToDisplay) 'Declared in display method cmdPriName.Invoke(delTest, "cmdPriName", sUIName, bEnable, bContinue, "fraName")'Called in the display method
The function(getControlToDisplay) gets called around 50 times for each component on the form to determine if a certain component should be visible or not depending on the type of account. Is a delegate used for multiple calls or is it a one time only type of thing?
Edit: I have found a way that works well but it's not calling the function as it should, it will get to the line and skip over it immediately without going to the function.
cmdPriName.Invoke(New testControlToDisplay(AddressOf getControlToDisplay), "cmdPriName", sUIName, bEnable, bContinue, "fraName")
This post has been edited by Criel: 30 August 2012 - 11:30 AM