コード例 #1
0
            public OperationResult DataReceived(int transferred, Direction direction)
            {
                var continuation = new OperationContinuation();

                queue.Add(continuation);
                return(continuation.Result);
            }
コード例 #2
0
            public override OperationResult DataReceived(int transferred, Direction direction)
            {
                // Call the base listener and return that value if it's not continue.

                var result = base.DataReceived(transferred, direction);

                if (result.Outcome != OperationOutcome.Continue)
                {
                    return(result);
                }

                // Create an operation continuation and schedule it to be ran after
                // some time.

                var continuation = new OperationContinuation();

                Task.Run(async() =>
                {
                    await Task.Delay(delay);

                    continuation.SetOutcome(OperationOutcome.Continue);
                });

                return(continuation.Result);
            }
コード例 #3
0
            public OperationResult DataReceived(int transferred, Direction direction)
            {
                var continuation = new OperationContinuation();

                continuation.SetOutcome(OperationOutcome.Continue);
                return(continuation.Result);
            }
コード例 #4
0
            public OperationResult GetResult(int bytesTransferred)
            {
                // Add our bytes transferred to the total.

                long transferred = Interlocked.Add(ref this.transferred, bytesTransferred);

                // If we went over our budget, delay the continuation of this
                // transfer and schedule it to be executed later.

                if (transferred > bandwidth)
                {
                    lock (syncRoot)
                    {
                        var continuation = new OperationContinuation();
                        continuations.Add(continuation);
                        return(continuation.Result);
                    }
                }

                return(OperationResult.Continue);
            }