public override int EndRead(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!async) { return(base.EndRead(asyncResult)); } AsyncResult ares = asyncResult as AsyncResult; if (ares == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } ReadDelegate r = ares.AsyncDelegate as ReadDelegate; if (r == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } return(r.EndInvoke(asyncResult)); }
public override int EndRead(IAsyncResult asyncResult) { AsyncResult result = (AsyncResult)asyncResult; ReadDelegate caller = (ReadDelegate)result.AsyncDelegate; return(caller.EndInvoke(asyncResult)); }
public BinaryReader EndRead(IAsyncResult ar) { AsyncResult a = (AsyncResult)ar; ReadDelegate d = (ReadDelegate)a.AsyncDelegate; return(d.EndInvoke(ar)); }
public void ShouldReadFileMultithreadedCorrectly() { ReadDelegate action = () => { using (var image = new MagickImage()) { image.Read(Files.Coders.CartoonNetworkStudiosLogoAI); Assert.AreEqual(765, image.Width); Assert.AreEqual(361, image.Height); Assert.AreEqual(MagickFormat.Ai, image.Format); } }; var results = new IAsyncResult[3]; for (int i = 0; i < results.Length; ++i) { results[i] = action.BeginInvoke(null, null); } for (int i = 0; i < results.Length; ++i) { action.EndInvoke(results[i]); } }
public override int EndRead(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult ar = asyncResult as AsyncResult; if (ar == null) { throw new ArgumentException("Invalid asyncResult", "asyncResult"); } ReadDelegate del = ar.AsyncDelegate as ReadDelegate; if (del == null) { throw new ArgumentException("Invalid asyncResult", "asyncResult"); } #if SSHARP return(del.EndInvokeEx <int> (asyncResult)); #else return(del.EndInvoke(asyncResult)); #endif }
public int EndRead(IAsyncResult result) { AsyncResult art = result as AsyncResult; ReadDelegate del = art.AsyncDelegate as ReadDelegate; int i = del.EndInvoke(result); return(i); }
protected static void EndRead(IAsyncResult ar) { HidAsyncState hidAsyncState = (HidAsyncState)ar.AsyncState; ReadDelegate readDelegate = (ReadDelegate)hidAsyncState.CallerDelegate; ReadCallback readCallback = (ReadCallback)hidAsyncState.CallbackDelegate; HidDeviceData data = readDelegate.EndInvoke(ar); readCallback?.Invoke(data); }
/// <summary> /// Called when bytes finish being read /// </summary> /// <param name="res">Contains the delegates involved in the read</param> private void AsyncReadEnd(IAsyncResult res) { // Pull the read function and callback out of the IAsyncResult object[] objects = res.AsyncState as object[]; ReadDelegate del = objects[0] as ReadDelegate; ReadCallback callback = objects[1] as ReadCallback; // Send the data up to the controller class callback.Invoke(del.EndInvoke(res)); }
public override int EndRead(IAsyncResult asyncResult) { AsyncResult result = asyncResult as AsyncResult; if (result == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } ReadDelegate r = result.AsyncDelegate as ReadDelegate; if (r == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } return(r.EndInvoke(asyncResult)); }
public override int EndRead(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult asyncResult2 = asyncResult as AsyncResult; if (asyncResult2 == null) { throw new ArgumentException("Invalid asyncResult", "asyncResult"); } ReadDelegate readDelegate = asyncResult2.AsyncDelegate as ReadDelegate; if (readDelegate == null) { throw new ArgumentException("Invalid asyncResult", "asyncResult"); } return(readDelegate.EndInvoke(asyncResult)); }
public void Test_Multithreading() { ReadDelegate action = delegate() { using (MagickImage image = new MagickImage()) { image.Read(Files.Coders.CartoonNetworkStudiosLogoAI); } }; IAsyncResult[] results = new IAsyncResult[3]; for (int i = 0; i < results.Length; ++i) { results[i] = action.BeginInvoke(null, null); } for (int i = 0; i < results.Length; ++i) { action.EndInvoke(results[i]); } }
public void ShouldReadFileMultithreadedCorrectly() { ReadDelegate action = () => { using (IMagickImage image = new MagickImage()) { image.Read(Files.Coders.CartoonNetworkStudiosLogoAI); Test_Image(image); } }; IAsyncResult[] results = new IAsyncResult[3]; for (int i = 0; i < results.Length; ++i) { results[i] = action.BeginInvoke(null, null); } for (int i = 0; i < results.Length; ++i) { action.EndInvoke(results[i]); } }
public override int EndRead(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } AsyncResult ar = asyncResult as AsyncResult; if (ar == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } ReadDelegate d = ar.AsyncDelegate as ReadDelegate; if (d == null) { throw new ArgumentException("Invalid IAsyncResult", "asyncResult"); } return(d.EndInvoke(asyncResult)); }
public override int EndRead(IAsyncResult asyncResult) { return(readDelegate.EndInvoke(asyncResult)); }