コード例 #1
0
        // make an async request to the scheduler that handles requests for the given target
        internal void AddAsyncRequest(DependencyObject target, AsyncDataRequest request)
        {
            if (target == null)
            {
                return;
            }

            // get the appropriate scheduler
            IAsyncDataDispatcher asyncDispatcher = AsyncDataDispatcher;

            /* AsyncDataDispatcher property is cut (task 41079)
             * IAsyncDataDispatcher asyncDispatcher = Binding.GetAsyncDataDispatcher(target);
             * if (asyncDispatcher == null)
             * {
             *  asyncDispatcher = AsyncDataDispatcher;
             * }
             */

            // add it to the list of schedulers that need cleanup
            if (_asyncDispatchers == null)
            {
                _asyncDispatchers = new HybridDictionary(1); // lazy instantiation
            }
            _asyncDispatchers[asyncDispatcher] = null;       // the value is unused

            // make the request
            asyncDispatcher.AddRequest(request);
        }
コード例 #2
0
        // Token: 0x060074CF RID: 29903 RVA: 0x00216970 File Offset: 0x00214B70
        private void ProcessRequest(object o)
        {
            AsyncDataRequest asyncDataRequest = (AsyncDataRequest)o;

            try
            {
                asyncDataRequest.Complete(asyncDataRequest.DoWork());
            }
            catch (Exception ex)
            {
                if (CriticalExceptions.IsCriticalApplicationException(ex))
                {
                    throw;
                }
                asyncDataRequest.Fail(ex);
            }
            catch
            {
                asyncDataRequest.Fail(new InvalidOperationException(SR.Get("NonCLSException", new object[]
                {
                    "processing an async data request"
                })));
            }
            object syncRoot = this._list.SyncRoot;

            lock (syncRoot)
            {
                this._list.Remove(asyncDataRequest);
            }
        }
コード例 #3
0
        // Token: 0x06007493 RID: 29843 RVA: 0x00215C30 File Offset: 0x00213E30
        private static object OnSetValueCallback(AsyncDataRequest adr)
        {
            AsyncSetValueRequest asyncSetValueRequest = (AsyncSetValueRequest)adr;
            ClrBindingWorker     clrBindingWorker     = (ClrBindingWorker)asyncSetValueRequest.Args[0];

            clrBindingWorker.PW.SetValue(asyncSetValueRequest.TargetItem, asyncSetValueRequest.Value);
            return(null);
        }
コード例 #4
0
ファイル: CLRBindingWorker.cs プロジェクト: ash2005/z
        static object OnSetValueCallback(AsyncDataRequest adr)
        {
            AsyncSetValueRequest request = (AsyncSetValueRequest)adr;
            ClrBindingWorker     worker  = (ClrBindingWorker)request.Args[0];

            worker.PW.SetValue(request.TargetItem, request.Value);
            return(null);
        }
コード例 #5
0
        //------------------------------------------------------
        //
        //  Interface: IAsyncDataDispatcher
        //
        //------------------------------------------------------

        /// <summary> Add a request to the dispatcher's queue </summary>
        void IAsyncDataDispatcher.AddRequest(AsyncDataRequest request)
        {
            lock (_list.SyncRoot)
            {
                _list.Add(request);
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessRequest), request);
        }
コード例 #6
0
        //------------------------------------------------------
        //
        //  Interface: IAsyncDataDispatcher
        //
        //------------------------------------------------------

        /// <summary> Add a request to the dispatcher's queue </summary>
        void IAsyncDataDispatcher.AddRequest(AsyncDataRequest request)
        {
            lock (_list.SyncRoot)
            {
                _list.Add(request);
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessRequest), request);
        }
コード例 #7
0
        // Token: 0x060074CD RID: 29901 RVA: 0x00216898 File Offset: 0x00214A98
        void IAsyncDataDispatcher.AddRequest(AsyncDataRequest request)
        {
            object syncRoot = this._list.SyncRoot;

            lock (syncRoot)
            {
                this._list.Add(request);
            }
            ThreadPool.QueueUserWorkItem(new WaitCallback(this.ProcessRequest), request);
        }
コード例 #8
0
        // Token: 0x06007494 RID: 29844 RVA: 0x00215C6C File Offset: 0x00213E6C
        private static object OnCompleteSetValueCallback(AsyncDataRequest adr)
        {
            AsyncSetValueRequest asyncSetValueRequest = (AsyncSetValueRequest)adr;
            ClrBindingWorker     clrBindingWorker     = (ClrBindingWorker)asyncSetValueRequest.Args[0];
            DataBindEngine       engine = clrBindingWorker.Engine;

            if (engine != null)
            {
                engine.Marshal(ClrBindingWorker.CompleteSetValueLocalCallback, asyncSetValueRequest, 1);
            }
            return(null);
        }
コード例 #9
0
        // Token: 0x0600748E RID: 29838 RVA: 0x00215A20 File Offset: 0x00213C20
        private static object OnGetValueCallback(AsyncDataRequest adr)
        {
            AsyncGetValueRequest asyncGetValueRequest = (AsyncGetValueRequest)adr;
            ClrBindingWorker     clrBindingWorker     = (ClrBindingWorker)asyncGetValueRequest.Args[0];
            object value = clrBindingWorker.PW.GetValue(asyncGetValueRequest.SourceItem, (int)asyncGetValueRequest.Args[1]);

            if (value == PropertyPathWorker.IListIndexOutOfRange)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            return(value);
        }
コード例 #10
0
        /// <summary> Cancel all requests in the dispatcher's queue </summary>
        void IAsyncDataDispatcher.CancelAllRequests()
        {
            lock (_list.SyncRoot)
            {
                for (int i = 0; i < _list.Count; ++i)
                {
                    AsyncDataRequest request = (AsyncDataRequest)_list[i];
                    request.Cancel();
                }

                _list.Clear();
            }
        }
コード例 #11
0
        // Token: 0x060074CE RID: 29902 RVA: 0x002168F8 File Offset: 0x00214AF8
        void IAsyncDataDispatcher.CancelAllRequests()
        {
            object syncRoot = this._list.SyncRoot;

            lock (syncRoot)
            {
                for (int i = 0; i < this._list.Count; i++)
                {
                    AsyncDataRequest asyncDataRequest = (AsyncDataRequest)this._list[i];
                    asyncDataRequest.Cancel();
                }
                this._list.Clear();
            }
        }
コード例 #12
0
ファイル: CLRBindingWorker.cs プロジェクト: ash2005/z
        static object OnCompleteSetValueCallback(AsyncDataRequest adr)
        {
            AsyncSetValueRequest request = (AsyncSetValueRequest)adr;
            ClrBindingWorker     worker  = (ClrBindingWorker)request.Args[0];

            DataBindEngine engine = worker.Engine;

            if (engine != null) // could be null if binding has been detached
            {
                engine.Marshal(CompleteSetValueLocalCallback, request);
            }

            return(null);
        }
コード例 #13
0
        // Token: 0x060074B7 RID: 29879 RVA: 0x00216334 File Offset: 0x00214534
        internal void AddAsyncRequest(DependencyObject target, AsyncDataRequest request)
        {
            if (target == null)
            {
                return;
            }
            IAsyncDataDispatcher asyncDataDispatcher = this.AsyncDataDispatcher;

            if (this._asyncDispatchers == null)
            {
                this._asyncDispatchers = new HybridDictionary(1);
            }
            this._asyncDispatchers[asyncDataDispatcher] = null;
            asyncDataDispatcher.AddRequest(request);
        }
コード例 #14
0
        //------------------------------------------------------
        //
        //  Private methods
        //
        //------------------------------------------------------

        // Run a single request.  This method gets scheduled on a worker thread
        // from the process ThreadPool.
        void ProcessRequest(object o)
        {
            AsyncDataRequest request = (AsyncDataRequest)o;

            // PreSharp uses message numbers that the C# compiler doesn't know about.
            // Disable the C# complaints, per the PreSharp documentation.
#pragma warning disable 1634, 1691

            // PreSharp complains about catching NullReference (and other) exceptions.
            // In this case, these are precisely the ones we want to catch the most,
            // so that a failure on a worker thread doesn't affect the main thread.
#pragma warning disable 56500

            // run the request - this may take a while
            try
            {
                request.Complete(request.DoWork());
            }

            // Catch all exceptions.  There is no app code on the stack,
            // so the exception isn't actionable by the app.
            // Yet we don't want to crash the app.
            catch (Exception ex)
            {
                if (CriticalExceptions.IsCriticalApplicationException(ex))
                {
                    throw;
                }

                request.Fail(ex);
            }
            catch // non CLS compliant exception
            {
                request.Fail(new InvalidOperationException(SR.Get(SRID.NonCLSException, "processing an async data request")));
            }

#pragma warning restore 56500
#pragma warning restore 1634, 1691

            // remove the request from the list
            lock (_list.SyncRoot)
            {
                _list.Remove(request);
            }
        }
コード例 #15
0
 static object OnGetValueCallback(AsyncDataRequest adr)
 { 
     AsyncGetValueRequest request = (AsyncGetValueRequest)adr;
     ClrBindingWorker worker = (ClrBindingWorker)request.Args[0];
     object value = worker.PW.GetValue(request.SourceItem, (int)request.Args[1]);
     if (value == PropertyPathWorker.IListIndexOutOfRange) 
         throw new ArgumentOutOfRangeException("index");
     return value; 
 } 
コード例 #16
0
 static object OnSetValueCallback(AsyncDataRequest adr) 
 { 
     AsyncSetValueRequest request = (AsyncSetValueRequest)adr;
     ClrBindingWorker worker = (ClrBindingWorker)request.Args[0]; 
     worker.PW.SetValue(request.TargetItem, request.Value);
     return null;
 }
コード例 #17
0
        static object OnCompleteSetValueCallback(AsyncDataRequest adr)
        { 
            AsyncSetValueRequest request = (AsyncSetValueRequest)adr; 
            ClrBindingWorker worker = (ClrBindingWorker)request.Args[0];
 
            Dispatcher dispatcher = worker.Dispatcher;
            if (dispatcher != null) // could be null if binding has been detached
            {
                dispatcher.BeginInvoke(DispatcherPriority.DataBind, 
                                          CompleteSetValueLocalCallback,
                                          request); 
            } 

            return null; 
        }
コード例 #18
0
ファイル: CLRBindingWorker.cs プロジェクト: JianwenSun/cc
        static object OnCompleteSetValueCallback(AsyncDataRequest adr)
        {
            AsyncSetValueRequest request = (AsyncSetValueRequest)adr;
            ClrBindingWorker worker = (ClrBindingWorker)request.Args[0];

            DataBindEngine engine = worker.Engine;
            if (engine != null) // could be null if binding has been detached
            {
                engine.Marshal(CompleteSetValueLocalCallback, request);
            }

            return null;
        }
コード例 #19
0
ファイル: DataBindEngine.cs プロジェクト: JianwenSun/cc
        // make an async request to the scheduler that handles requests for the given target
        internal void AddAsyncRequest(DependencyObject target, AsyncDataRequest request)
        {
            if (target == null)
                return;

            // get the appropriate scheduler
            IAsyncDataDispatcher asyncDispatcher = AsyncDataDispatcher;
            /* AsyncDataDispatcher property is cut (task 41079)
            IAsyncDataDispatcher asyncDispatcher = Binding.GetAsyncDataDispatcher(target);
            if (asyncDispatcher == null)
            {
                asyncDispatcher = AsyncDataDispatcher;
            }
            */

            // add it to the list of schedulers that need cleanup
            if (_asyncDispatchers == null)
            {
                _asyncDispatchers = new HybridDictionary(1);    // lazy instantiation
            }
            _asyncDispatchers[asyncDispatcher] = null;  // the value is unused

            // make the request
            asyncDispatcher.AddRequest(request);
        }