I am currently looking at processing 2 data downloads from a WCF service that return collections of different objects and was wondering if there was a better method than running the two asynchronous tasks synchronously.
In this case can I implement as Task.WhenAll or Task.WhenAny methodology to run these tasks in parallel?
Public Property Users As IEnumerable(Of UserDto)
Get
Return _users
End Get
Set(value As IEnumerable(Of UserDto))
_users = value
RaisePropertyChanged("Users")
End Set
End Property
Public Property ApplicationRoles() As IEnumerable(Of ApplicationRoleDto)
Get
Return _roles
End Get
Set(ByVal value As IEnumerable(Of ApplicationRoleDto))
_roles = value
RaisePropertyChanged("ApplicationRoles")
End Set
End Property
Private Async Sub GetUserDetails()
Users = Await _serviceHelper.GetUsers()
ApplicationRoles = Await _serviceHelper.GetApplicationRoles
End Sub
Possible solution
I could use the Task Parrallel Library but I am not sure if this is the most efficient method, plus I can't await the return.
Parallel.Invoke(Sub() Users = _serviceHelper.GetUsers(),
Sub() ApplicationRoles = _serviceHelper.GetApplicationRoles())