views:

62

answers:

0

Hello all I have a problem, I am writing an import CSV to silverlight MVVM the problem I am having is I loop the lines of the stream and then add them to an array, 2 items in the array need to be looked up for the ID I can do that but the problem is they run on a different thread how do I wait for that to return its results and then process the rest of that array? This is all being done on the Viewmodel.vb file to save round trip time.

Here is what I have so far: Private Function ProcessRow(ByVal stringRow As String) As Boolean Dim linedata() As String Dim PersonId As Integer Dim EventDateTime As String Dim EquipmentId As Integer Dim MeterReading As Integer Dim additionalValue As String Dim EventType As Integer Dim TotalCost As Double Dim ImportId As Integer

  linedata = stringRow.Split(CChar(","))
  ExternalUserId = CInt(linedata(0))
  GetUserId()
  CheckWaiting(ReturnedUserId)
  PersonId = CInt(ReturnedUserId)
  If PersonId = 0 Then
    Return False
  End If
  GetVehicleId(CInt(linedata(1)), 103)
  EquipmentId = CInt(ExternalVehicleId)
  If EquipmentId = 0 Then
    Return False
  End If
  EventDateTime = FormatDatatime(linedata(2), linedata(3))
  MeterReading = CInt(linedata(11))
  additionalValue = linedata(9)
  EventType = 6
  TotalCost = GetTotalCost(CInt(linedata(9)), CDbl(linedata(10)))
  Return True
End Function

Public Sub GetUserId()
  Dim c As New PersonSearchCriteria
  c.Externalid = CInt(ExternalUserId)
  c.ModuleId = 103
  _personproxy.BeginFindPersonList(AddressOf OnFindPersonListComplete, c)
 End Sub

 Private Sub OnFindPersonListComplete(ByVal pList As ObservableCollection(Of PersonDisplay))
  Personlist = pList
  If Personlist.Count > 0 Then
    ReturnedUserId = CInt(Personlist.Item(0).Id)
  Else
    ReturnedUserId = 0
  End If
 End Sub

Thank you for any help. Tim