造成大量无休止AsyncTasks的超慢的应用 [英] Super slow apps caused by large number of unending AsyncTasks

查看:210
本文介绍了造成大量无休止AsyncTasks的超慢的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道,但我的应用程序是完全有时熄火(不响应触摸屏)我以为我是在下面的线程的所有规则,但我的应用程序显然是放慢Sprint的EVO!我从来没有使用我自己的一样慢的应用程序。我没有得到一个ANR对话框,但我想我大概应该得到越来越之一。我不知道如何使这个应用程序运行就像我曾经使用过所有其他的应用程序 - 不结冰。这难道不是一个好主意,有一个的HttpClient 并保持静态引用它希望所有使用它的活动?我用来创建一个新的每次,并认为这改变一个加速起来。我没有 AsyncTasks 永远结束。如果我去到活动A - > B - >Ç - > D中第一次将是顺利的。我可以preSS回来,但是当我回到A,其完全冻结,不响应任何东西。这时候,我把那个截图。我真的不知道我在做什么错。我应该手动杀了我对 Activity.onPause AsyncTasks()

I have no idea, but my app is stalling sometimes completely (not responding to touching the screen) I thought I was following all the rules for threading, but my app is apparently slowing down the Sprint EVO! I have never used an app as slow as my own. I don't get an ANR dialog, though I think I probably should get getting one. I have no idea how to make this application run like every other app I've ever used -- Not freezing. Is it not a good idea to have one HttpClient and keep a static reference to it for all Activities that want to use it? I used to create a new one each time, and thought that changing it to one sped it up. None of my AsyncTasks ever end. If I go to Activity A -> B -> C -> D the first time it will be smooth. I can press back but when I get back to A, its completely frozen, not responding to anything. That when I took that screenshot. I really have no clue what I am doing wrong. Should I manually kill my AsyncTasks on Activity.onPause()?

推荐答案

我不知道你的活动冻结......这让我觉得,你要进入一个无限循环中的上preExecute onPostExecute()您的AsyncTask的,但谁知道。

I'm not sure about your Activity freezing... it makes me think that you're getting into an infinite loop in onPreExecute or onPostExecute() of your AsyncTask, but who knows.

我不知道但是,你应该使用 ThreadSafeClientConnManager 如果你要分享你的的HttpClient 多个线程之间。

I do know, however, that you should be using a ThreadSafeClientConnManager if you're going to share your HttpClient between multiple threads.

    // Create the client.  We can cache and reuse this client because we're using a
    // ThreadSafeClientConnManager, which will create a pool of connections for us 
    // to use across multiple threads.
    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setSoTimeout(params, TIMEOUT);
    HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(
            new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
    httpClient = new DefaultHttpClient(cm, params);

这篇关于造成大量无休止AsyncTasks的超慢的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆