コード例 #1
0
        protected override IAsyncResult BeginLoadUser(AsyncCallback callback, object state)
        {
            IAsyncResult result = new FakeAsyncResult(state);

            Deployment.Current.Dispatcher.BeginInvoke(() => callback(new FakeAsyncResult(state)));
            return(result);
        }
コード例 #2
0
        protected override sealed IAsyncResult BeginSubmitCore(EntityChangeSet changeSet, AsyncCallback callback, object userState)
        {
            FakeAsyncResult asyncResult = null;

            try
            {
                IEnumerable <ChangeSetEntry> operationResults = this.Submit(changeSet);
                asyncResult = new FakeAsyncResult
                {
                    Callback         = callback,
                    AsyncState       = userState,
                    ChangeSet        = changeSet,
                    OperationResults = operationResults
                };
            }
            catch (Exception error)
            {
                asyncResult = new FakeAsyncResult {
                    Callback = callback, AsyncState = userState, Error = error
                };
            }

            this.syncContext.Post(
                o =>
            {
                ((FakeAsyncResult)o).Complete();
            },
                asyncResult);

            return(asyncResult);
        }
コード例 #3
0
        protected override sealed SubmitCompletedResult EndSubmitCore(IAsyncResult asyncResult)
        {
            FakeAsyncResult localAsyncResult = (FakeAsyncResult)asyncResult;

            if (localAsyncResult.Error == null)
            {
                return(new SubmitCompletedResult(localAsyncResult.ChangeSet, localAsyncResult.OperationResults));
            }
            else
            {
                throw localAsyncResult.Error;
            }
        }
コード例 #4
0
        protected override sealed IAsyncResult BeginQueryCore(EntityQuery query, AsyncCallback callback, object userState)
        {
            var results = this.Query(query);
            //Debug.WriteLine(query.Query.ToString());
            var asyncResult = new FakeAsyncResult
            {
                Callback   = callback,
                AsyncState = userState,
                Entities   = results.ToArray(),
                TotalCount = results.Count()
            };

            this.syncContext.Post(cb => ((FakeAsyncResult)cb).Complete(), asyncResult);

            return(asyncResult);
        }