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
All Controls implement the ISynchronizeInvoke (http://msdn.microsoft.com/en-us/library/system.componentmodel.isynchronizeinvoke.aspx) interface. Where you need to call ThreadProc, you might code:
If Form1.InvokeRequired Then
Form1.Invoke(AddressOf ThreadProc)
Else
ThreadProc()
End If
Thank you