daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// Startup part
  2.     private async Task handleAsyncStuff()
  3.     {
  4.         await StartAndDoStuff();
  5.     }
  6.  
  7.     private async Task StartAndDoStuff()
  8.     {
  9.         BusyIndicatorMessage = "This should start and do stuff async, but it doesn't feel like?";
  10.         var data = await LoadDataFromCache();
  11.         BusyIndicatorMessage = "This is loading async";
  12.         data = await updateCache();
  13.         this.collection1 = new ObservableCollection<Category>(data);
  14.         this.collection2 = new QueryableCollectionView(collection1);
  15.         this.chosencollection = collection2;
  16.         InvokeOnUIThread(() => {
  17.             this.spinningbar = false;
  18.             this.message = "Why didn't the spinningbar load?";
  19.         });
  20.         await _functions.DoOtherStuffWithoutBlockingTheViewWithASpinningBar();
  21.     }
  22.  
  23.  // Event part
  24.  
  25.     private async void SelectionChanged(object sender, EventArgs e)
  26.     {
  27.         HandleFilterOnSelectionChanged();
  28.         await Task.Run(async () => {
  29.             InvokeOnUIThread(() => spinningbar= true);
  30.             await OnSelectionChanged();
  31.         });
  32.     }
  33.  
  34.     private async void HandleFilterOnSelectionChanged()
  35.     {
  36.  
  37.             this.collection.FilterDescriptors.Remove(filterDescriptor);
  38.  
  39.               this.filterDescriptor = new FilterDescriptor
  40.               {
  41.                   Member = "Date",
  42.                   Operator = FilterOperator.IsEqualTo,
  43.                   Value = DateTime.Now
  44.               };
  45.  
  46.  
  47.             this.collection.FilterDescriptors.Add(filterDescriptor);
  48.         }
  49.     }
  50.  
  51.      private async Task OnSelectionChanged()
  52.     {
  53.         this.categories = new ObservableCollection<Category>(await GetCategoriesAsync();
  54.         this.textLine = "Is This Running Async?";
  55.         InvokeOnUIThread(() => Spinningbar = false);
  56.     }
  57.  
  58.     public async Task<List<Category>> GetCategoriesAsync()
  59.     {
  60.         var category = new List<Category>();
  61.  
  62.         // SQL Logic
  63.  
  64.         return category;
  65.     }
  66.  
  67.  
  68.     public class Contructor ()
  69.     {
  70.       AsyncContext.Run(GetStuffForTheApplication);
  71.     }
  72.  
  73.  
  74.     public async Task GetStuffForTheApplication()
  75.     {
  76.         Task.Run(async () => {
  77.             InvokeOnUIThread(() => spinningbar = true);
  78.             RunCacheHandler();                
  79.             this.GetStuff = new ObservableCollection<BasePeak>(await GetStuffsync());
  80.         });
  81.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top