Link to home
Start Free TrialLog in
Avatar of Kevin Robinson
Kevin Robinson

asked on

Loading Data Async

I am try to load some of my data asynchronously using the code below.   But I am getting the error.

Cross-thread operation not valid: Control 'dg_Contacts' accessed from a thread other than the thread it was created on.
Private M_LoadContactAsync As WCF_Contacts.Contact.DelLoadContact

    Public Sub LoadContactAsync()
        M_LoadContactAsync = AddressOf Me.Contact.LoadContacts
        M_LoadContactAsync.BeginInvoke(Me.M_OrgID, AddressOf CallBackLoadAddress, Nothing)
    End Sub
    Public Sub CallBackLoadAddress(ByVal r As IAsyncResult)
        Me.Contacts = Me.M_LoadContactAsync.EndInvoke(r)
        Me.dg_Contacts.DataSource = Me.Contacts
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial