Private mTable As agDBConnect.Table Private autoResetEvent As New System.Threading.AutoResetEvent(False) Public Sub GetTableCompleted(sender As Object, e As agDBConnect.GetTableCompletedEventArgs) Try Me.Dispatcher.BeginInvoke(New Action(Of agDBConnect.Table)(AddressOf FillTable), e.Result) autoResetEvent.Set() Catch ex As Exception End Try End Sub Private Sub FillTable(aTab As agDBConnect.Table) mTable = aTab End Sub Private Sub DoGetTable() AddHandler myagDBConnect.GetTableCompleted, AddressOf GetTableCompleted While myagDBConnect.State <> ServiceModel.CommunicationState.Opened End While myagDBConnect.GetTableAsync("SELECT * from s3USER") autoResetEvent.WaitOne() End Sub Private Async Sub btTestData_Click(sender As Object, e As RoutedEventArgs) Handles btTestData.Click Try Try mTable = Nothing Dim myThread As System.Threading.Thread = New Thread(AddressOf DoGetTable) myThread.Start() While myThread.ThreadState = ThreadState.Running End While '>> don't want to be here until gettablecomplete has done If mTable IsNot Nothing AndAlso mTable.Rows.Count > 0 Then txtDebug.Text = mTable.Rows(0).Columns(0).FieldName End If Catch ex As Exception End Try Catch ex As Exception MessageBox.Show(ex.ToString, "System Error", MessageBoxButton.OK) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)