Skip to content

Commit

Permalink
Word Export: prevent cross-thread exception (#184)
Browse files Browse the repository at this point in the history
* Word Export: prevent cross-thread exception

Use InvokeRequired and Invoke to re-execute the TextForReal call.

Notes:
- XHTML export is also calling this from a different thread but we
were not seeing this error because the text string was the same
as the current value so no change was made.
- The exception was only happening when there were reversals
and it seemed to only/mostly happen in debug builds.
  • Loading branch information
mark-sil authored Jan 16, 2025
1 parent 3b4d220 commit 9cb20de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Src/Common/Controls/FwControls/StatusBarTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ public string TextForReal
{
CheckDisposed();

if (m_bar.InvokeRequired)
{
m_bar.Invoke((Action<string>)(s => this.TextForReal = s), value);
return;
}

m_text = value;
// But we still need to set the Text property to get autosizing to work.
this.Text = m_text;
Expand Down

0 comments on commit 9cb20de

Please sign in to comment.