BlackBerry - 未捕获的异常:应用程序没有响应;流程终止

时间:2010-12-07 11:34:09

标签: blackberry blackberry-eclipse-plugin

我正在使用Blackberry插件开发一个用于eclipse的应用程序,当我将应用程序部署到生产服务器和手机时调用Web服务时出现以下错误...它在我的本地工作模拟器和开发环境。 (我无法将我的模拟器直接挂钩到我的生产环境中)

  

未捕获的异常:应用程序   app(150)没有响应;处理   终止

正在从另一个线程进行调用。

将线程传递给我的CustomThreadManager以运行

ClientChangeThread thread = new ClientChangeThread();
CustomThreadManager.Start(thread, true);

CustomThreadManager

ProgressPopup _progress = null; 
    if(showProgress){
        _progress = new ProgressPopup("Loading...");
        _progress.Open();
    }
    thread.start();             

    while (thread.isRunning())
    {
        try
        {
            CustomThread.sleep(300);
            if(showProgress){
                _progress.doPaint();
            }
        }
        catch (InterruptedException e)
        {
            Dialog.alert("Error contacting webservice\n" + e.getMessage());
            Functions.moveBack();
        }                   
    }
    if(showProgress)
        _progress.Close();

有些电话有效,有些则不用。 Web服务很快返回结果,因此我不确定它的Web服务是否太慢或者是否存在线程问题。

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:4)

Thread。sleep()不释放任何锁。这意味着更新while循环中进度条的代码持有UI事件锁,并阻止其他UI更新发生,直到while循环终止 - 在这种情况下,当thread.isRunning()返回false时。

您可以使用UiApplication.invokeLater(Runnable, long, boolean)来安排重复的UI更新,该更新只会在Runnable执行时保留事件锁定。