Friday, May 11, 2007

And the award goes to...

The award for most... let's call it "innovative"... use of a C# Hashtable and an AsyncResult goes to:


private Hashtable _asyncResultToStudyUidMap = new Hashtable();


... later ...

IAsyncResult asyncResult =
_services.OrderService.BeginGetOrderForStudyPartially(
orderId, studyId, orderPropertyArray, new
AsyncCallback(RequestOrderInfoCompleted), null);

_asyncResultToStudyUidMap[asyncResult] = studyUid;


... later ...

string studyUid = (string) _asyncResultToStudyUidMap[asyncResult];

if (studyUid != null)
{
_cachedDictationInfos[studyUid] = dictationInfo;
_asyncResultToStudyUidMap.Remove(asyncResult);
}


In case you're wondering, yes, we really are using the AsyncResult as the key to the Hashtable.

()

0 comments: