Esempio n. 1
0
 protected override IEnumerator <Step> Steps()
 {
     yield return(Step.Await(
                      this,
                      (thisPtr, c, s) => new CompletedAsyncResult <int>(1, c, s),
                      (thisPtr, r) => thisPtr.ThrowSync(CompletedAsyncResult <int> .End(r))));
 }
Esempio n. 2
0
 protected override IEnumerator <Step> Steps()
 {
     yield return(Step.Await(
                      this,
                      (thisPtr, c, s) => thisPtr.ThrowSync(),
                      (thisPtr, r) => thisPtr.Invalid()));
 }
Esempio n. 3
0
 protected override IEnumerator <Step> Steps()
 {
     yield return(Step.Await(
                      this,
                      (thisPtr, c, s) => thisPtr.result = new AsyncResult <bool>(c, s),
                      (thisPtr, r) => ((AsyncResult <bool>)thisPtr.result).EndInvoke(),
                      Catch <ArgumentException> .AndHandle(this, (thisPtr, e) => thisPtr.ThrowFromHandler())));
 }
Esempio n. 4
0
            protected override IEnumerator <Step> Steps()
            {
                yield return(Step.Await(
                                 false,
                                 (t, c, s) => new CompletedAsyncResult <bool>(t, c, s),
                                 (t, r) => CompletedAsyncResult <bool> .End(r)));

                throw this.exception;
            }
Esempio n. 5
0
 protected override IEnumerator <Step> Steps()
 {
     yield return(Step.Await(
                      this,
                      (thisPtr, c, s) => thisPtr.Throw(),
                      (thisPtr, r) => Invalid(),
                      Catch <Exception> .AndHandle(this, (thisPtr, e) => false),
                      Catch <InvalidTimeZoneException> .AndHandle(this, (thisPtr, e) => false)));
 }
Esempio n. 6
0
            protected override IEnumerator <Step> Steps()
            {
                using (MemoryStream outputStream = new MemoryStream())
                    using (this.stream = new FileStream(this.path, FileMode.Open, FileAccess.Read, FileShare.Read, this.bufferSize, true))
                    {
                        this.buffer = new byte[this.bufferSize];
                        do
                        {
                            Console.WriteLine("[{0}] Reading...", Thread.CurrentThread.ManagedThreadId);
                            yield return(Step.Await(
                                             this,
                                             (thisPtr, c, s) => thisPtr.stream.BeginRead(thisPtr.buffer, 0, thisPtr.bufferSize, c, s),
                                             (thisPtr, r) => thisPtr.bytesRead = thisPtr.stream.EndRead(r)));

                            Console.WriteLine("[{0}] Read {1} bytes.", Thread.CurrentThread.ManagedThreadId, this.bytesRead);
                            if (this.bytesRead > 0)
                            {
                                outputStream.Write(this.buffer, 0, this.bytesRead);
                            }
                        }while (this.bytesRead > 0);

                        this.Result = outputStream.ToArray();
                    }
            }