/// <summary> /// Tell the thread to stop. Called from UI thread. /// </summary> internal void quit() { lock (this) { mQuit = true; wakeup(); Log.d("ddms", "Waiting for Monitor thread"); try { thread.Join(); // since we're quitting, lets drop all the client and disconnect // the DebugSelectedPort lock (mClientList) { foreach (Client c in mClientList) { c.close(false); // notify broadcast(CLIENT_DISCONNECTED, c); } mClientList.Clear(); } if (mDebugSelectedChan != null) { mDebugSelectedChan.close(); mDebugSelectedChan.socket().Close(); mDebugSelectedChan = null; } mSelector.close(); } catch (ThreadInterruptedException ie) { Console.WriteLine(ie.ToString()); Console.Write(ie.StackTrace); } catch (IOException e) { // TODO Auto-generated catch block Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } mInstance = null; } }
/// <summary> /// Close the socket that's listening for new connections and (if /// we're connected) the debugger data socket. /// </summary> /*lock*/ internal void close() { try { if (mListenChannel != null) { mListenChannel.close(); } mListenChannel = null; closeData(); } catch (IOException) { Log.w("ddms", "Failed to close listener " + this); } }