Sep 16, 2009
I am trying to access the checked state of a CheckBox from a BackGroundWorker thread. I am utilizing properties and it seemed to work just fine. However, I'm using 10-15 CheckBoxes and I think using the InvokeRequired property would probably be best. I've looked over JMC's thread that talks about how to access controls from the worker thread a bunch of different times and I can't seem to grasp the concepts. When it comes to the InvokeRequired property, I suppose I understand why it is needed. But I'm not sure if I understand it completely.
View 9 Replies
From the example that JMC provides:
Private Sub ResetTextBoxText()
If Me.TextBox1.InvokeRequired Then
Me.TextBox1.Invoke(New MethodInvoker(AddressOf ResetTextBoxText))
If I'm not mistaken, this tells us that if invocation is required to access the control, then we access via the MethodInvoker if not, then we just access to directly? So, if I need to check the checked state of a check box, I know I can just put a conditional statement after the Else line if I can access it directly. But, if I can't how would I use MethodInvoker to check the checked state? And then, when calling it from the worker thread, would I just call the sub?