Here is the scenario.
I have a WinForm application(C#, .NET 3.5) that follows the Asynchronous Event-Based design pattern.
The main control(MainResultControl) creates multiple instances of child controls(ResultControl) as the user requests. Each child control has unique set of parameters that users selects.
Each child control then calls WCF service asynchronously:
WebServiceClient.GetResultsAsync(Parameters param)
Each child control also signs up for GetResultsCompleted event of the Web Service
WebServiceClient.GetResultsCompleted += _service_GetResultsCompleted()
Here is the problem that we are facing. Users complain that sometimes ResultControl displays the unexpected set of data - unrelated to what they requested.
Is it possible that one instance of control receives the results that the other instance requested when it handles GetResultsCompleted event raised in the web service?
Thank you.
Here is some supporting code(VB): The parent control(MainResultControl)
Private Sub Submit_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles tbSubmit.Click
'a copy of MyRequestArgs is created with the details of request'
pnlResult.Controls.Add(new ResultsControl(_myRequestArgs))
End Sub
The child control(ResultsControl):
Public Class ResultsControl
Public _webRequestResult As WebRequestResult
Public Sub New(ByVal _requestArgs As MyRequestArgs)
Dim _service as MyWebService()
_service.GetTripSolutionsAsync(New TripPlannerParameters() _
With {.ApplicationID = _requestArgs.ApplicationID, _
.Arrival = _requestArgs.Parameters.Arrival, _
.Destination = _requestArgs.Parameters.Destination})
End Sub
Private Sub _service_GetTripSolutionsCompleted(ByVal sender As Object, _
ByVal e As MyWebService.ResultCompletedEventArgs) Handles _service.GetTripSolutionsCompleted
'Validation of correct results is done here
'Skipped for simplicity
_webRequestResult = DirectCast(e.Result, WebRequestResult)
End Sub
End Class
EDIT:
I consulted some people and it seems that WCF has some methods of ensuring that event raised from the service is handled by the proper object (on the client machine) that raised it. The idea is - WCF utilizes different IP sockets on the client machine for multiple asynchronous requests. Is that true?