void quietInterval_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (SourceArea == null || DrawArea == null) { return; } quietInterval.Stop(); // here is where we could generate the diagram... String txt = ""; Application.Current.Dispatcher.Invoke(() => { txt = SourceArea.Text; }); // here's where we would produce the diagram... // now invoke the WPF thread to draw it... var diagram = Parser.Parse(new Tokenizer(txt)); var renderer = new Renderer(DrawArea, diagram); Application.Current.Dispatcher.Invoke(() => { renderer.Draw(); SrcErrorState = diagram.HasErrors; }); }