Beispiel #1
0
        protected void LoadAsync(LoadStartAsync startMethod, LoadFinishAsync finishMethod)
        {
            IsBusy = true;
            var loadData = startMethod;

            loadData.BeginInvoke(delegate(IAsyncResult ar)
            {
                var bindData = (LoadStartAsync)ar.AsyncState;
                bindData.EndInvoke(ar);
                if (finishMethod != null)
                {
                    finishMethod();
                }

                IsBusy = false;
            }, loadData);

            var dispather = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, startMethod);

            dispather.Completed += delegate
            {
                if (finishMethod != null)
                {
                    finishMethod();
                }

                IsBusy = false;
            };
        }
Beispiel #2
0
 protected void LoadAsync(LoadStartAsync startMethod)
 {
     IsBusy = true;
     Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(
                                                  delegate
     {
         startMethod();
         IsBusy = false;
     }));
 }