|
Re: best way to distinguish main ui thread and background threads [message #1732888 is a reply to message #1732881] |
Sun, 22 May 2016 06:44 |
Ed Merks Messages: 33107 Registered: July 2009 |
Senior Member |
|
|
Tass,
Try org.eclipse.swt.widgets.Display.getCurrent().
On 22.05.2016 01:50, Tass Burrfoot wrote:
> Hello
>
> I have a method that should be accessed only by background threads. I
> want to throw AssertionError if the method is accessed by the main UI
> thread.
>
> I tried
> if (Display.findDisplay(Thread.currentThread())!=null)
> but this line throws illegal state exception itself.
>
> If I print thread name directly by
> Thread.currentThread().getName()
> it prints: UIThread [...]
>
> Is there any way to get the main thread name "UIThread [...]" from RAP
> api? For now I store the main thread name to a static variable when
> the application starts up. That's not handy. What is the best way to
> check whether the executing thread is main thread or background thread
> in RAP? Thanks
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03158 seconds