Beispiel #1
0
        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));
        }
Beispiel #2
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            AsyncResult  result = (AsyncResult)asyncResult;
            ReadDelegate caller = (ReadDelegate)result.AsyncDelegate;

            return(caller.EndInvoke(asyncResult));
        }
Beispiel #3
0
        public BinaryReader EndRead(IAsyncResult ar)
        {
            AsyncResult  a = (AsyncResult)ar;
            ReadDelegate d = (ReadDelegate)a.AsyncDelegate;

            return(d.EndInvoke(ar));
        }
Beispiel #4
0
        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]);
            }
        }
Beispiel #5
0
        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);
            }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        /// <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));
        }
Beispiel #9
0
        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));
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        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]);
            }
        }
Beispiel #12
0
        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));
        }
Beispiel #14
0
 public override int EndRead(IAsyncResult asyncResult)
 {
     return(readDelegate.EndInvoke(asyncResult));
 }