我有一些代码,a)大约需要10.20秒来执行b)返回一个用于进一步处理的值( c)由用户调用
因此,我创建了这样一个结构:
ProgressDialog pd = new ProgressDialog(ctx);
pd.setCancelable(false);
pd.setCanceledOnTouchOutside(false);
pd.setTitle(ctx.getResources().getText(R.string.progress));
pd.setMessage(ctx.getResources().getText(R.string.wait_keygen));
pd.setIndeterminate(true);
returnValue=doSomeDifficultCalculationsHere();
pd.dismiss();现在我的问题是:进度对话没有显示,它似乎也被阻塞的doSomeDifficultCalculationsHere()-function阻塞了。
当我将doSomeDifficultCalculationsHere()放入自己的线程并执行Thread.join()以等待该函数的结果时,也不会显示对话,因为Thread.join()阻塞了。
当我将ProgressDialog放到线程中时,我会得到一个异常。
那么,如果不能真正异步调用ProgressDialog (),那么我还能如何解决这个问题,并让ProgressDialog显示出来,因为以下所有步骤都需要它的结果?
谢谢!
发布于 2013-11-13 11:31:46
你需要在pd.show()之前做returnValue=doSomeDifficultCalculationsHere();
https://stackoverflow.com/questions/19952625
复制相似问题