There is new WaitScreen component in Mobility Pack 5.0. You can use it for a task that usually takes lot of time (like connectiong to server) and can either succes or fail. It used Runnable and it failed when a RuntimeException appeared. We discovered that it doesn't fit to all users.
The task doesn't fail when any exception appeared.
Look at the code.
simpleCancellableTask1 = new org.netbeans.microedition.util.SimpleCancellableTask();
simpleCancellableTask1.setRunnable(new Runnable() {
public void run() {
try {
//some code here
} catch (java.io.IOException ioe) {
throw new RuntimeException(ioe.getMessage());
}
}
});
Isn't it strange? You catch an exception and throw new RuntimeException. Why? It should be simplier.
This is the reason why we decided to change the API of SimpleCancellableTask
simpleCancellableTask1 = new org.netbeans.microedition.util.SimpleCancellableTask();
simpleCancellableTask1.setExecutable(new org.netbeans.microedition.util.Executable() {
public void execute() throws Exception {
//your code here
}
});
Note that any exception can be thrown in this second snip of code and when an exception appears then the task fails. That's exactly what you'd expect, wouldn't you?
Important note: - if you have an simpleCancellableTask from previous 5.0 build (beta or a build before 11/01) then it will be automaticaly regenerated to new syntax after a change in your Visual MIDlet.
- f you wrote a call to the setRunnable method by hand then you have to change it to setExecutable.
|
Posted by Matthew Ford on November 04, 2005 at 01:03 AM CET #
<b>org.netbeans.microedition.util</b>
<br>
where can if find the Library/package of this Class
Posted by sherwin corpuz on August 14, 2008 at 04:09 AM CEST #
I have a problem with this,
i am calling waiting screen and in turn Task
on the action event of a button
//CODE
switchDisplayable(null, getWaitScreen());
//CODE OVER
but now when i cancel back to the same form and even i have made waitScreen and Task as null,
now if i perform action Event
task is not getting exweecuted.......
Posted by Jigar on July 28, 2009 at 03:33 PM CEST #