コード例 #1
0
        /// <summary>
        /// Adds callbacks to the set of callbacks that are executed at
        /// various points during the processing of a request.
        /// </summary>
        /// <param name="callbacks">Callbacks to be executed.</param>
        public void AddCallbacks(IProducerContextCallbacks callbacks)
        {
            bool cancelImmediately = false;

            lock (_gate)
            {
                _callbacks.Add(callbacks);
                if (_isCancelled)
                {
                    cancelImmediately = true;
                }
            }

            if (cancelImmediately)
            {
                callbacks.OnCancellationRequested();
            }
        }
コード例 #2
0
        public void Initialize()
        {
            // Initializes the mock producer listener
            ProducerListenerImpl producerListener = new ProducerListenerImpl(
                (_, __) => { },
                (_, __, ___) => { },
                (_, __, ___) => { },
                (_, __, ___, ____) => { },
                (_, __, ___) => { },
                (_) =>
            {
                return(false);
            });

            // Initializes the mock producer context callbacks
            _callbacks1 = new BaseProducerContextCallbacks(
                () =>
            {
                ++_onCancellationRequestedCount1;
            },
                () =>
            {
                ++_onIsPrefetchChangedCount1;
            },
                () =>
            {
                ++_onIsIntermediateResultExpectedChangedCount1;
            },
                () =>
            {
                ++_onPriorityChangedCount1;
            });

            _callbacks2 = new BaseProducerContextCallbacks(
                () =>
            {
                ++_onCancellationRequestedCount2;
            },
                () =>
            {
                ++_onIsPrefetchChangedCount2;
            },
                () =>
            {
                ++_onIsIntermediateResultExpectedChangedCount2;
            },
                () =>
            {
                ++_onPriorityChangedCount2;
            });

            _settableProducerContext = new SettableProducerContext(
                IMAGE_REQUEST,
                REQUEST_ID,
                producerListener,
                new object(),
                RequestLevel.FULL_FETCH,
                false,
                true,
                Priority.MEDIUM);
        }