/// <summary> /// This performs the spell checking process and updates the adorner when the timer elapses /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private async void timer_Elapsed(object sender, ElapsedEventArgs e) { await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { if (dictionary != null && dictionary.IsReadyForUse) { System.Diagnostics.Debug.WriteLine("WpfTextBoxSpellChecker: Spell checking textbox"); this.CheckSpelling(textBox.Text); adorner.UpdateMisspellings(misspelledWords); } #if DEBUG else { System.Diagnostics.Debug.WriteLine("WpfTextBoxSpellChecker: Dictionaries not ready for use. Waiting..."); } #endif } catch (Exception ex) { // Ignore exceptions System.Diagnostics.Debug.WriteLine(ex); } }
/// <summary> /// This performs the spell checking process and updates the adorner when the timer elapses /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private async void timer_Elapsed(object sender, ElapsedEventArgs e) { await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { this.CheckSpelling(textBox.Text); adorner.UpdateMisspellings(misspelledWords); } catch (Exception ex) { // Ignore exceptions System.Diagnostics.Debug.WriteLine(ex); } }
/// <summary> /// This performs the spell checking process and updates the adorner when the timer elapses /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void timer_Elapsed(object sender, ElapsedEventArgs e) { Application.Current.Dispatcher.Invoke(new Action(() => { try { this.CheckSpelling(textBox.Text); adorner.UpdateMisspellings(misspelledWords); } catch (Exception ex) { // Ignore exceptions System.Diagnostics.Debug.WriteLine(ex); } })); }