Skip to main content

BackgroundTask + Dialog

1 reply [Last post]
francisdb
Offline
Joined: 2006-06-16

Hi,

As I am used to swingworker in swing I'm trying to do the same in lwuit by extending the BackgroundTask

Id like to show a loading dialog while the Task is working.

private class MyTask extends BackgroundTask {

final Dialog dialog = new Dialog("loading...");

public void taskStarted() {
dialog.show();
}
....

but the show() is blocking and the task never runs.

Before trying this I used to create the dialog, start a thread and dispose the dialog at the end of that thread (using callserially). I start the thread and call dialog.show().

What's the best way to do this using the BackgroundTask abstract class?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi Francisdb,
spawn the task thread and then open the dialog:

class MyTask extends ... implements Runnable {
// ...
public void startTask() {
new Thread(this).start();
dialog.show();
}

public void run() {
// ... perform task
dialog.dispose();
}
// ...
}

Thanks,
Shai.

> Hi,
>
> As I am used to swingworker in swing I'm trying to do the same in
> lwuit by extending the BackgroundTask
>
> Id like to show a loading dialog while the Task is working.
>
> private class MyTask extends BackgroundTask {
>
> final Dialog dialog = new Dialog("loading...");
>
> public void taskStarted() {
> dialog.show();
> }
> ....
>
> but the show() is blocking and the task never runs.
>
> Before trying this I used to create the dialog, start a thread and
> dispose the dialog at the end of that thread (using callserially).
> I start the thread and call dialog.show().
>
> What's the best way to do this using the BackgroundTask abstract
> class?
> [Message sent by forum member 'francisdb' (francisdb)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282461
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net