WinCE下的LCD调节和测试帮手

android
的AysncTask直接调用Execute会在在多个线程池里按调用的先后顺序依次执行。

   
在骨子里项目中,平时会基于分化接纳配备不一致尺寸的LCD。所以要求针对区别的LCD,调节相应的参数。近期的一个门类,先后用了五、陆、7和八寸屏,分辨率都是800*480。由于显得驱动是本地驱动,不可能动态卸载和加载。而在平等分辨率的意况下,分歧的LCD仅仅是相应的行场同步参数不平等。所以,为了便于调节和测试,针对TCC89平台做了个LCD调节和测试帮手,能够在应用程序中央直机关接修改行场同步参数,实时调节和测试LCD。为了印证参数的科学,简单做了三个用来测试的界面。

如果运用的享有网络获得都依赖这么些来做,当有2个互连网请求柱塞,就导致别的请求也柱塞了。

  
LCD调节和测试帮手的界面如下图所示,重要提供了三种已知LCD的参数,并能够自由修改当中的一点项。
图片 1

在三.0 以往引进了新的艺术。能够不在多个线程池里运营。

   方今合龙了各样分裂型号的LCD参数设置,如下图所示。
图片 2

class TaskHelper {

    public static <P, T extends AsyncTask<P, ?, ?>> void execute(T task) {
        execute(task, (P[]) null);
    }

    @SuppressLint("NewApi")
    public static <P, T extends AsyncTask<P, ?, ?>> void execute(T task, P... params) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
        } else {
            task.execute(params);
        }
    }
}

    
用于测试参数正确性的界面如下图所示,以3个像素的幅度画了三个矩形框。通过观察其在LCD上的体现效果,很不难就能判断出当下参数是或不是科学。

 

图片 3

asyncTask.execute

Note: this function schedules the task on a queue for a single
background thread or pool of threads depending on the platform
version. When first introduced, AsyncTasks were executed serially on a
single background thread. Starting with
android.os.Build.VERSION_CODES.DONUT, this was changed to a pool of
threads allowing multiple tasks to operate in parallel. After
android.os.Build.VERSION_CODES.HONEYCOMB, it is planned to change
this back to a single thread to avoid common application errors caused
by parallel execution. If you truly want parallel execution, you can
use the executeOnExecutor version of this method with
THREAD_POOL_EXECUTOR; however, see commentary there for warnings on
its use. 

This method must be invoked on the UI thread.必须UI线程中调用

只顾:那么些函数让义务是以单线程队列格局或线程池队列情势运转,依赖于阳台版本而有所分裂。asyncTask第1次引进时,那些函数会让职分之后台单线程串行方式执行。从android.os.Build.VE卡宴SION_CODES.DONUT(android
1.陆)早先,它让允许职责在线程池中多任务并行执行。但在 android.os.Build.VEEscortSION_CODES.HONEYCOMB(android
3.0)之后,它又该回去了,变成了单线程执行的情势,原因是二十四线程并行执行不难引发难点。假若您真想并行执行任务,你能够动用别的二个本子:使用THREAD_POOL_EXECUTOPRADO参数的executeOnExecutor方法,但要注意运用警告提醒

anyncTask.executeOnExecutor

This method is typically used with THREAD_POOL_EXECUTOR to allow
multiple tasks to run in parallel on a pool of threads managed by
AsyncTask, however you can also use your own Executor for custom
behavior. 

Warning: Allowing multiple tasks to run in parallel from a thread pool
is generally not what one wants, because the order of their operation
is not defined. For example, if these tasks are used to modify any
state in common (such as writing a file due to a button click), there
are no guarantees on the order of the modifications. Without careful
work it is possible in rare cases for the newer version of the data to
be over-written by an older one, leading to obscure data loss and
stability issues. Such changes are best executed in serial; to
guarantee such work is serialized regardless of platform version you
can use this function with SERIAL_EXECUTOR. 
This method must be invoked on the UI thread.
Parameters:
exec The executor to use. THREAD_POOL_EXECUTOR is available as a
convenient process-wide thread pool for tasks that are loosely
coupled.

这一个主意1般和THREAD_POOL_EXECUTOQashqai一起行使,允许几个任务在由AsyncTask管理的线程池中并行执行,可是你你也得以应用自定义行为的Executor。

 

警示:因为执行操作顺序并未有定义,平时状态下,允许八个职务在线程池中并行执行,其结果毫无是您想要的。例如:那几个职务都要去修改某些状态值(诸如点击按钮写文件),因为尚未分明的改动顺序,旧的改动可能会覆盖新修改的版本内容,导致不安静数据丢失而成为一个祥和的标题。由此这种职责最为是串行执行;确定保障那些任务串行执行而不正视于阳台版本的点子是,使用SETiggoIAL_EXECUTOR

   
其它,这几个小工具须要使用WinCE桌面帮手球组织助调试,因为假设设置的参数与LCD对应的参数大有不一样,就很难在LCD上经过触摸屏修改参数,而不得不用WinCE桌面助手远程修改。

 

   
有了这些小工具,在调节和测试LCD的长河中有益广大,无须编写翻译BOOT或是根本,就能印证参数是不是科学,进步了调节的功用。