public static void DoWork() { int i; MagCard_Activity obj = new MagCard_Activity(); while (runflag) { Message msg = new Message(); msg = hand.ObtainMessage(); // Message msg = Handler...obtainMessage(); if (!runflag) { break; } // Log.d(TAG, "Magcard ------> Thread"); if ((i = obj.MgcardAPI.Read(obj.MagcardNo)) > 0) { // Log.d(TAG, "Send The Message to the ReadHandler"); hand.SendMessage(msg); } else { //Log.d(TAG, "Read error ========="); // System.out.println(i); // Log.d(TAG, "Read error ========="); } } }
public static void run() { byte[] Data = new byte[8]; byte[] tmpData; mHandler hand = new mHandler(); Ibutton_Activity obj = new Ibutton_Activity(); while (stopflag) { Message msg = hand.ObtainMessage(); tmpData = obj.aclasHdqApi.Read(); if (ArrayZero(tmpData)) { // Log.d(TAG, "no data"); msg.Arg1 = 1; } else { msg.Arg2 = 0; } if (ArrayCmp(tmpData, Data)) { //Log.d(TAG, "the same data continue"); try { Thread.Sleep(500); } catch (ThreadInterruptedException e) { // TODO Auto-generated catch block //e.printStackTrace(); Console.WriteLine(e.ToString().ToCharArray()); } continue; } else { System.Array.Copy(tmpData, 0, Data, 0, 8); obj.cardNo = ByteArrayToString(Data); } hand.SendMessage(msg); // Log.d(TAG, "Hdq -------> Thread"); try { // sleep(500); //200ms Thread.Sleep(500); } catch (ThreadInterruptedException e) { // TODO Auto-generated catch block // e.printStackTrace(); Console.WriteLine(e.ToString().ToCharArray()); } if (!stopflag) { break; } } }