private void UpdateCollection()
        {
            // (Konrad) We pass a list of items already selected so that we can update them rather than create a new list.
            var selected  = View._listBox.SelectedItems;
            var scheduler = DynamoViewmodel.Model.Scheduler;
            var delegateBasedAsyncTask = new DelegateBasedAsyncTask(scheduler, delegate
            {
                ViewModel.PopulateItems(selected);
            });

            delegateBasedAsyncTask.ThenSend(delegate { }, SyncContext);
            scheduler.ScheduleForExecution(delegateBasedAsyncTask);
        }
Ejemplo n.º 2
0
        private void OnRequestScheduledTask(Action action)
        {
            var s = dynamoViewModel.Model.Scheduler;

            var t = new DelegateBasedAsyncTask(s, () =>
            {
            });

            t.ThenSend((_) =>
            {
                action();
            }, syncContext);

            s.ScheduleForExecution(t);
        }
Ejemplo n.º 3
0
        private void UpdateParameterSelector()
        {
            var scheduler = _dynamoViewmodel.Model.Scheduler;
            var delegateBasedAsyncTask = new DelegateBasedAsyncTask(scheduler, delegate
            {
                _viewModel.PopulateItems();
            });

            delegateBasedAsyncTask.ThenSend(delegate
            {
                _viewModel.SelectedItem = _viewModel.SelectedItem ?? _viewModel.ItemsCollection.FirstOrDefault();
            }, _syncContext);

            scheduler.ScheduleForExecution(delegateBasedAsyncTask);
        }
Ejemplo n.º 4
0
        private void UpdateColorRange()
        {
            var s = dynamoViewModel.Model.Scheduler;

            // prevent data race by running on scheduler
            var t = new DelegateBasedAsyncTask(s, () =>
            {
                colorRange = colorRangeNode.ComputeColorRange(dynamoModel.EngineController);
            });

            // then update on the ui thread
            t.ThenSend((_) =>
            {
                var bmp = CreateColorRangeBitmap(colorRange);
                gradientImage.Source = bmp;
            }, syncContext);

            s.ScheduleForExecution(t);
        }
Ejemplo n.º 5
0
 protected DelegateBasedAsyncTask AsyncThenUI(DelegateBasedAsyncTask task, Action action)
 {
     task.ThenSend((_) => action?.BeginInvoke(action.EndInvoke, null), syncContext);
     return(task);
 }