How are you attempting to use TaskAdapter? TaskAdapter wraps a TaskListener and 
is only called once when the task completes. It sounds like you want to update 
your label multiple times while the task is executing, so TaskAdapter wouldn't 
help with that.
G

On Jul 12, 2011, at 12:02 PM, Edgar Merino wrote:

> Although I do have a question here, I though executing a Task using a 
> TaskAdapter to wrap the TaskListener was supposed to have this same outcome, 
> but I'm not able to change the label using a Task instead of a Runnable, can 
> anyone explain this please?
> 
> 
> El 12/07/11 10:37, Edgar Merino escribió:
>> Thank you Chris, that did the trick!
>> 
>> El 12/07/11 00:48, Chris Bartlett escribió:
>>> Edgar,
>>> 
>>> Search the mailing list archives for previous posts that refer to 
>>> 'ApplicationContext.queueCallback(Runnable)'
>>> 
>>> apache-pivot-users.399431.n3.nabble.com
>>> apache-pivot-developers.417237.n3.nabble.com
>>> 
>>> It is used to queue a Runnable to be executed on the UI thread. If wrap 
>>> your call to label.setText() in a Runnable, and execute with 
>>> queueCallback(), you should see the label update properly.
>>> 
>>> Chris
>>> 
>>> -----Original Message-----
>>> From: Edgar Merino<[email protected]>
>>> Sent: 12 July 2011 08:07
>>> To: [email protected]
>>> Subject: Task countdown and Labels
>>> 
>>> Hello, I'm trying to implement a simple countdown animation using a Task
>>> and a Label: when the task is executed, it goes through a loop that
>>> repeats five times and does two things here: update the label with the
>>> current counter and sleep a second. However, sometimes I don't see the
>>> label updating until some processing on the application is finished, is
>>> there a way to force the application to wait for the label to be updated
>>> first before trying to assign a different value to its text property?
>>> Here's some sample code:
>>> 
>>> 
>>> public class CountdownTask extends Task {
>>> 
>>>      private Label label;
>>> 
>>>      public CountdownTask(Label label) {
>>>          this.label = label;
>>>      }
>>> 
>>>      public void execute() {
>>>          for (int i = 5; i>= 0; i--) {
>>>              label.setText(i+1);
>>> 
>>>              Thread.sleep(1000);
>>>          }
>>>      }
>>> }
>>> 
>>> I've tried running this both sync and async and I always get the same
>>> result.
>>> 
>>> Thanks in advance,
>>> Edgar Merino
>>> 

Reply via email to