private void btnConnect_Click(object sender, EventArgs e) { CConnectionContext cc = new CConnectionContext(txtHost.Text, 20902, txtUser.Text, txtPassword.Text); m_spMysql = new CSocketPool <CMysql>(false); //set event for MySQL/Mariadb database shutdown m_spMysql.SocketPoolEvent += new CSocketPool <CMysql> .DOnSocketPoolEvent(m_spMysql_SocketPoolEvent); if (!m_spMysql.StartSocketPool(cc, 1, 1)) { txtMessage.Text = "No connection to " + txtHost.Text; return; } CMysql mysql = m_spMysql.AsyncHandlers[0]; //set event for tracking all database table update events, delete, update and insert m_spMysql.Sockets[0].Push.OnPublish += new DOnPublish(Push_OnPublish); //create a DB session with default to sample database sakil bool ok = mysql.Open("sakila", null, DB_CONSTS.ENABLE_TABLE_UPDATE_MESSAGES); m_ds = new DataSet("real-time cache"); DataTable dt = null; string errMsg = ""; //query all cached tables into client side for intial cache data ok = mysql.Execute("", (h, ret, err_msg, affected, fail_ok, id) => { //this callback is fired from worker thread from socket pool thread ok = (ret == 0); errMsg = err_msg; }, (h, data) => { //this callback is fired from worker thread from socket pool thread CMysql.AppendRowDataIntoDataTable(data, dt); }, (h) => { //this callback is fired from worker thread from socket pool thread dt = CMysql.MakeDataTable(h.ColumnInfo); string name = h.ColumnInfo[0].DBPath + "." + h.ColumnInfo[0].TablePath; dt.TableName = name; m_ds.Tables.Add(dt); }); ok = mysql.WaitAll(); txtMessage.Text = errMsg; lstTables.Items.Clear(); foreach (DataTable table in m_ds.Tables) { lstTables.Items.Add(table.TableName); } if (m_ds.Tables.Count > 0) { lstTables.SelectedIndex = 0; } btnDisconnect.Enabled = ok; btnConnect.Enabled = !ok; }