Author | Message | Time |
---|---|---|
Spilled[DW] | Okay I will have a class that will have 2 threads sent to it. My question is what will be the best way for those threads to access a function that accesses 2 of my controls(listbox and a trackbar) that is in my form1 class without crossthreading? Ex:(form1.vb) public function INeedToAccessThis() as string 'do stuff with listbox 'do stuff with trackbar return infoneeded end function ex: Class1 public sub ThreadProc() 'need to call form1.INeedToAccessThis end sub | December 2, 2008, 1:46 AM |
Myndfyr | All Controls implement the ISynchronizeInvoke interface. Where you need to call ThreadProc, you might code: [code] If Form1.InvokeRequired Then Form1.Invoke(AddressOf ThreadProc) Else ThreadProc() End If [/code] | December 2, 2008, 4:14 PM |
Spilled[DW] | Thank you | December 2, 2008, 8:41 PM |