public IAsyncResult BeginGetResponse <TBody>(string url, AsyncCallback asyncCallback, object state) { var asyncResult = new HttpClientAsyncResult <TBody>(asyncCallback, state); var descriptorDict = new Dictionary <string, object>() { { "url", url }, { "asyncResultAddress", ManagedGCHandle.FromObject((IMarkCompleted)asyncResult).Address } }; BeginFetch(MiniJSON.Json.Serialize(descriptorDict)); return(asyncResult); }
private static int OnFetchCompleted(string descriptor) { var parsed = (IDictionary <string, object>)MiniJSON.Json.Deserialize(descriptor); var asyncResultAddress = (int)parsed["asyncResultAddress"]; using (var asyncResultHandle = ManagedGCHandle.FromAddress <IMarkCompleted>(asyncResultAddress)) { var asyncResult = asyncResultHandle.Value; asyncResult.MarkAsCompleted((IDictionary <string, object>)parsed["response"]); return(0); } }