Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Startup part
- private async Task handleAsyncStuff()
- {
- await StartAndDoStuff();
- }
- private async Task StartAndDoStuff()
- {
- BusyIndicatorMessage = "This should start and do stuff async, but it doesn't feel like?";
- var data = await LoadDataFromCache();
- BusyIndicatorMessage = "This is loading async";
- data = await updateCache();
- this.collection1 = new ObservableCollection<Category>(data);
- this.collection2 = new QueryableCollectionView(collection1);
- this.chosencollection = collection2;
- InvokeOnUIThread(() => {
- this.spinningbar = false;
- this.message = "Why didn't the spinningbar load?";
- });
- await _functions.DoOtherStuffWithoutBlockingTheViewWithASpinningBar();
- }
- // Event part
- private async void SelectionChanged(object sender, EventArgs e)
- {
- HandleFilterOnSelectionChanged();
- await Task.Run(async () => {
- InvokeOnUIThread(() => spinningbar= true);
- await OnSelectionChanged();
- });
- }
- private async void HandleFilterOnSelectionChanged()
- {
- this.collection.FilterDescriptors.Remove(filterDescriptor);
- this.filterDescriptor = new FilterDescriptor
- {
- Member = "Date",
- Operator = FilterOperator.IsEqualTo,
- Value = DateTime.Now
- };
- this.collection.FilterDescriptors.Add(filterDescriptor);
- }
- }
- private async Task OnSelectionChanged()
- {
- this.categories = new ObservableCollection<Category>(await GetCategoriesAsync();
- this.textLine = "Is This Running Async?";
- InvokeOnUIThread(() => Spinningbar = false);
- }
- public async Task<List<Category>> GetCategoriesAsync()
- {
- var category = new List<Category>();
- // SQL Logic
- return category;
- }
- public class Contructor ()
- {
- AsyncContext.Run(GetStuffForTheApplication);
- }
- public async Task GetStuffForTheApplication()
- {
- Task.Run(async () => {
- InvokeOnUIThread(() => spinningbar = true);
- RunCacheHandler();
- this.GetStuff = new ObservableCollection<BasePeak>(await GetStuffsync());
- });
- }
Add Comment
Please, Sign In to add comment