简体   繁体   English

同步解析getInBackground()与另一个线程

[英]Sync parse getInBackground() with another thread

In android, we can sync two threads with tools like pipes, handlers, shared memory ... I would like to do this with a "parse thread". 在android中,我们可以使用管道,处理程序,共享内存等工具同步两个线程...我想用“解析线程”来做这个。 The idea is that we have two threads, main thread and the thread created by getInBackground() like a simple query: 我们的想法是我们有两个线程,主线程和getInBackground()创建的线程就像一个简单的查询:

ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>() {
  public void done(ParseObject object, ParseException e) {
    if (e == null) {
      // object will be your game score
    } else {
      // something went wrong
    }
  }
});

I do not want to show a white screen forcing to the user wait. 我不想显示白屏强迫用户等待。 I would like to show a cached listView of the last results (main thread), while the device is downloading the data (Parse thread). 我想显示最后结果(主线程)的缓存listView,同时设备正在下载数据(解析线程)。 When the device would have downloaded all the information, the listView must be updated with the new data. 当设备下载了所有信息时,必须使用新数据更新listView。 I do not know If I have explained myself propertly... 我不知道如果我已经解释了自己的财产......

use AsyncTask 使用AsyncTask

in the doInBackGround() method do your download and in onPostExecute() method do the ListView update doInBackGround()方法中执行下载并在onPostExecute()方法中执行ListView更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM