private void AsyncRequestCompleted(IAsyncResult result, uint requestId, uint typeId)
{
lock (m_outstandingRequests)
{
// remove the request.
AsyncRequestState state = RemoveRequest(result, requestId, typeId);
if (state != null)
{
// mark any old requests as default (i.e. the should have returned before this request).
DateTime maxAge = state.Timestamp.AddSeconds(-1);
for (LinkedListNode<AsyncRequestState> ii = m_outstandingRequests.First; ii != null; ii = ii.Next)
{
if (ii.Value.RequestTypeId == typeId && ii.Value.Timestamp < maxAge)
{
ii.Value.Defunct = true;
}
}
}
// add a dummy placeholder since the begin request has not completed yet.
if (state == null)
{
state = new AsyncRequestState();
state.Defunct = true;
state.RequestId = requestId;
state.RequestTypeId = typeId;
state.Result = result;
state.Timestamp = DateTime.UtcNow;
m_outstandingRequests.AddLast(state);
}
}
}