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 IAsyncResult BeginGetResponse(string url, AsyncCallback asyncCallback, object state) { var asyncResult = new HttpClientAsyncResult(asyncCallback, state); var gcHandle = GCHandle.Alloc(asyncResult, GCHandleType.Pinned); var descriptorDict = new Dictionary <string, object>() { { "url", url }, { "asyncResultAddress", gcHandle.AddrOfPinnedObject().ToInt32() } }; BeginFetch(Json.Serialize(descriptorDict)); return(asyncResult); }
private IAsyncResult BeginResponse(string method, string url, string body, string mediaType, AsyncCallback asyncCallback, object state) { Console.WriteLine($"CALLED BeginResponse({method}, {url}, {body}, {mediaType}, ...)"); var asyncResult = new HttpClientAsyncResult(asyncCallback, state); var gcHandle = GCHandle.Alloc(asyncResult, GCHandleType.Pinned); var descriptorDict = new Dictionary <string, object>() { { "method", method }, { "body", body }, { "mediaType", mediaType }, { "url", url }, { "asyncResultAddress", gcHandle.AddrOfPinnedObject().ToInt32() } }; BeginFetch(Json.Serialize(descriptorDict)); Console.WriteLine($"RETURNING BeginResponse({method}, {url}, {body}, {mediaType}, ...)"); return(asyncResult); }