Example #1
0
        /// <summary>
        /// Calculates integral with given inputs.
        /// </summary>
        private async void ExecuteCalculateCommand(object parameter)
        {
            _isCalculating = true;
            CalculateCommand.RaiseCanExecuteChanged();

            // Compiles formula expression and gets function pointer on formula.
            var cr = await _compiler.Compile(Formula).ConfigureAwait(false);

            if (cr.Errors.Count == 0)
            {
                // f is function pointer.
                var f = _compiler.GetLambda(cr);
                Result = await _calculator.Integrate(f, From, To, N);
            }

            Application.Current.Dispatcher.Invoke(() =>
            {
                // Enables "Calculate" button.
                _isCalculating = false;
                CalculateCommand.RaiseCanExecuteChanged();
            });
        }