private async void btn_update_Click(object sender, EventArgs e) { //chưa sửa if (txt_ip.Text.Replace(".", "_") == ip.ipAddress) { this.Close(); } //check IP ipCheck = Task.Run(() => ipConn.GetWithKey(txt_ip.Text.Replace(".", "_"))).Result; if (ipCheck != null) { MessageBox.Show("IP đã tồn tại!"); return; } this.Enabled = false; bool success = false; int loop = 0; do { if (loop == 10) { break; } try { //Xóa cái cũ await ipConn.Delete(ip.ipAddress); //Thêm cái mới ip.ipAddress = txt_ip.Text.Replace(".", "_"); await ipConn.Insert(ip); success = true; } catch { loop++; Thread.Sleep(2000); } } while (!success); if (!success) { MessageBox.Show("Đã thử " + loop + " lần mà *** đc :))"); this.Enabled = true; } this.Enabled = true; this.Close(); }