void FirstCompilation() { string ResultStr = String.Empty; DynamicCompile.CompileCode("return 0;", out ResultStr); Dispatcher.BeginInvoke(new Action(OpenMainWindow)); }
public void CompileCodeThreadFunc() { try { string Code = EditorCode.Dispatcher.Invoke(new Func <string>(() => { return(EditorCode.Text); })); string ResultStr = String.Empty; Brush TextColor = CompiledColor; if (Code == String.Empty) { ResultStr = String.Empty; } else { if (!DynamicCompile.CompileCode(Code, out ResultStr)) { TextColor = ErrorColor; } else if (ResultStr == String.Empty) // Nothing to return, like with code: "Math.Pow(2, 2)" { string ResultStrPrev = ResultStr; if (!DynamicCompile.CompileCode("return " + Code + "", out ResultStr)) // If error - take last result without "return". { ResultStr = ResultStrPrev; } } } PlotViewer.Dispatcher.Invoke(() => { PlotViewer.Model = Plot.Model; PlotViewer.InvalidatePlot(); }); EditorResult.Dispatcher.Invoke(() => { EditorResult.Text = ResultStr; EditorResult.Foreground = TextColor; }); } catch { } }