惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 聂微东
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
美团技术团队
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
博客园_首页
宝玉的分享
宝玉的分享
C
Check Point Blog
爱范儿
爱范儿
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
U
Unit 42
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
博客园 - Franky
博客园 - 【当耐特】
腾讯CDC
N
Netflix TechBlog - Medium
Jina AI
Jina AI
博客园 - 司徒正美
Last Week in AI
Last Week in AI
PCI Perspectives
PCI Perspectives
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
J
Java Code Geeks
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
L
LINUX DO - 最新话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Security Affairs
Recent Announcements
Recent Announcements
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Secure Thoughts

博客园 - 狂野都城

一次分布式事务管理器(MSDTC)的事务处理异常的排错 FMS3.5 的logs 日志目录配置 C#磁盘大小管理操作类 C#建立IIS虚拟目录站点 IO操作类 同步和异步方式获取网页源代码! 判断一幅图片是否是黑色,灰度直方图 winform窗体置前 关于FMS服务端数据流发布 如何配置FMS边缘服务器 Windows服务“允许服务与桌面交互”的使用和修改方法 招聘:Flash视频开发程序员(网络多媒体应用) 招聘:windows mobile 手机应用软件的开发 Word 2007 里头鼠标失效(滚轮除外) ,困扰多天! 终止线程 Response.End 在Asp.net 里面的正确使用 Access 中查询TOP语句的奇怪问题??? 一道小学数学题... net常用代码 (收藏) 在VS2005 开发中使用Codesmith 和NetTiers 模版开发相关
后台线程处理
狂野都城 · 2011-07-25 · via 博客园 - 狂野都城

/*
  * 处理后台线程
  */
 public void doBackGround(){
 

  if(!CurInfo.Info.ai_logined){
   //Toast.makeText( this, "正在获取数据...", Toast.LENGTH_SHORT ).show();
   
   /*
   // 这里这个参数指定的是线程的名字 
         HandlerThread handlerThread = new HandlerThread("MyHandler"); 
         // 在使用HandlerThread的getLooper()方法之前,必须先调用该类的start(); 
         handlerThread.start();// 启动这个线程 
         //handlerThread.getLooper();
         MyHandler myHandler = new MyHandler(handlerThread.getLooper());
        
         */
   
   
         /*
         // 这里这个obtainMessage()方法返回 
         Message msg = myHandler.obtainMessage(); 
         // 将msg发送到目标对象,所谓的目标对象,就是生成该msg对象的handler对象 
         Bundle b = new Bundle(); 
         b.putInt("age", 20); 
         b.putString("name", "Jhon"); 
         msg.setData(b); 
         msg.sendToTarget(); 
         */
        
         new MyAsyncTask().doInBackground();
  }
 }

/*
  * 线程处理
  */
 class MyHandler extends Handler { 
        public MyHandler() {
         
        } 
 
        public MyHandler(Looper looper) { 
            super(looper);
            // 这里处理任务
           
            String result = AIData.aiInfo.loginHouse("999", "888");            
            if(result != "error"){             
             AIData.aiInfo.GetDeviceList(3); 
             CurInfo.Info.ai_SeeionId = result;
    CurInfo.Info.ai_logined = true;
            }
           
           
        } 
 
        @Override 
        public void handleMessage(Message msg) { 
            // 这里我们只做了简单的输出 
         /*
            Bundle b = msg.getData(); 
            int age = b.getInt("age"); 
            String name = b.getString("name"); 
            System.out.println("age is " + age + ", name is" + name); 
            System.out.println("Handler--->" + Thread.currentThread().getId()); 
            System.out.println("handlerMessage");
            */ 
        } 
    } 
 /*
  * 线程处理
  */
 private class MyAsyncTask extends AsyncTask<Void, Void, Void> {
   @Override
      protected Void doInBackground(Void... params) {
          //耗时操作,后台线程处理
          try {
              //Thread.sleep(4*1000);
             
              String result = AIData.aiInfo.loginHouse("999", "888");            
              if(result != "error"){             
               AIData.aiInfo.GetDeviceList(3); 
               CurInfo.Info.ai_SeeionId = result;
      CurInfo.Info.ai_logined = true;
              }             
             
          } catch (Exception  e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return null;
      }
      @Override
      protected void onPostExecute(Void result) {
          //作UI线程的修改。
          //progressDialog.dismiss();
          super.onPostExecute(result);
      }  
   }