我写了一些 Asynccall 来在服务器中运行一些东西。他们工作正常。但是有些任务需要很长时间才能运行。我想知道他们在执行过程中的状态。然后我编写了新的 Asynccall,它定期向服务器发送查询以检查任务的状态。但是对于回调,我只能得到失败消息。我查看了日志,这个 AsyncCallbak 无法执行。谁能给我一些建议?
private BackendRemoteServiceAsync service = GWT.create(BackendRemoteService.class);
Timer timer = new Timer() {
public void run() {
try {
ApplicationController controller = ApplicationController
.getInstance();
BackendRequest request = new BackendRequest(
Command.COMMAND_TASK_CHECKSTATUS,
controller.getSessionToken());
request.setDomain(Domains.TASK);
...
service.callBackend(request, new AsyncCallback<BackendRequest>() {
public void onFailure(Throwable caught) {
task.setStatus("check status failure");
}
public void onSuccess(BackendRequest result) {
if (result.isValid()) {
task.setStatus("check status Success"); ...
} else
;
}
});
} catch (IllegalArgumentException ex) {
Window.alert("IllegalArgumentException: "+ ex.getMessage());
} catch (Throwable t) {
Window.alert(t.getMessage());
} finally {
}
}
};
timer.scheduleRepeating(5000);