views:

53

answers:

0

I have a delegate for a method. I start it in a new thread that has a parameter in it in which I pass a DataView into. The new thread is obviously not running on the UI thread so I should not be accessing any UI controls. The dataview I am passing into the delegated method however I got the reference from ComboBox.DataSource where ComboBox is a UI control. Is this still safe because I am just passing in the reference to the object that the UI control is using and am just using that reference in the delegated method on the new thread and not accessing the control in anyway?

I believe this to be a safe thing to do, but want to ask the Threading Experts...

Delegate Sub GetPartListDataFromServer(ByVal dvOriginal As DataView, ByVal ProgramID As Integer)

Running on UI thread:

Public Sub Something()     
 Dim dlgGetPartList As New GetPartListDataFromServer(AddressOf AsyncThreadMethod_GetPartListDataFromServer)
        dlgGetPartList.BeginInvoke(ucboPart.DataSource, ucboProgram.Value, AddressOf AsyncCallback_GetPartListDataFromServer, Nothing) 
End Sub

Running on new thread:

Sub AsyncThreadMethod_GetPartListDataFromServer(ByVal dvOriginal As DataView, ByVal ProgramID As Integer)

        System.Threading.Thread.Sleep(5000)
End Sub