0

I created a custom eclipse editor and I need to set the status message in background (another thread). The message is too costly to be calculated and I need to run in background. To set this message I use this code:

    IActionBars actionBars = this.getEditorSite().getActionBars();
    actionBars.getStatusLineManager().setMessage(text);

And to run In background, I tried to create new Java Thread and I got the error "invalid thread access exception". I tried to use Display.getDefault().asyncExec and syncExec, but Its not run in background.

Thanks a lot.

Computered
  • 440
  • 1
  • 7
  • 21
  • 1
    There's an Eclipse FAQ article to that problem: https://wiki.eclipse.org/FAQ_Why_do_I_get_an_invalid_thread_access_exception%3F – Calon Nov 03 '14 at 12:41
  • In this article that I saw Display.getDefault().asyncExec and syncExec, but not work... – Computered Nov 03 '14 at 12:58
  • 3
    You can calculate the text in a background thread but you must use asyncExec or syncExec to actually set the message. – greg-449 Nov 03 '14 at 13:11
  • How can I calculate it and knows when finish to call setMessage? Can you show me some code example? Thks – Computered Nov 03 '14 at 13:51
  • I used SwingUtilities.invokeLater to calculate, and inside the invokeLater I call Display.getDefault().asyncExec to set message, I think its works... – Computered Nov 03 '14 at 14:35
  • 1
    Don't mix Swing and SWT. Just start a new thread instead of using SwingUtilities.invokeLater. – Konstantin Komissarchik Nov 03 '14 at 17:43
  • Ah, so you are using Swing? Display.getDefault().* is SWT, so like Konstantin said, don't mix both. Here's a rough "pros and cons" thread about both frameworks: http://stackoverflow.com/questions/2306190/java-desktop-application-swt-vs-swing – Calon Nov 04 '14 at 05:48

0 Answers0