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

推荐订阅源

I
InfoQ
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Martin Fowler
Martin Fowler
Security Latest
Security Latest
Cisco Talos Blog
Cisco Talos Blog
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
IT之家
IT之家
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园_首页
L
LINUX DO - 最新话题
Know Your Adversary
Know Your Adversary
S
Schneier on Security
The Last Watchdog
The Last Watchdog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
G
GRAHAM CLULEY
Y
Y Combinator Blog
P
Palo Alto Networks Blog
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
The Register - Security
The Register - Security
T
The Exploit Database - CXSecurity.com
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
Cyberwarzone
Cyberwarzone
雷峰网
雷峰网
T
Tailwind CSS Blog
V2EX - 技术
V2EX - 技术
T
Threat Research - Cisco Blogs
S
Secure Thoughts
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
O
OpenAI News
C
Cyber Attacks, Cyber Crime and Cyber Security
The Cloudflare Blog
量子位
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
S
SegmentFault 最新的问题
小众软件
小众软件
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security

博客园 - 狂野都城

一次分布式事务管理器(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);
      }  
   }