private void buttonConnect_Click(object sender, EventArgs e) { if (AdbCommand.DeviceConnected()) { toolStripStatusLabelText.Text = "设备已连接"; } else { toolStripStatusLabelText.Text = "设备未连接"; toolStripStatusLabelDeviceTime.Text = ""; } }
private void CheckConnectionState() { // 确保adb服务运行 AdbCommand.AdbStartServer(); while (true) { bool state = AdbCommand.DeviceConnected(); if (!state) { updateConnectionState.BeginInvoke(state, "", null, null); } else { string timeString = AdbCommand.GetDeviceDateTime(); updateConnectionState.BeginInvoke(state, timeString, null, null); } Thread.Sleep(5000); } }