[Ignore("dotnet core seems to keep objects alive")] // reference https://github.com/dotnet/coreclr/issues/13490
        public void ConnectionCloseByGC()
        {
            int threadId;
            ConnectionClosedCheck check = new ConnectionClosedCheck();

            MySqlConnectionStringBuilder connStr = new MySqlConnectionStringBuilder(Connection.ConnectionString);

            connStr.Pooling = false;
            MySqlConnection c = new MySqlConnection(connStr.GetConnectionString(true));

            c.StateChange += new StateChangeEventHandler(check.stateChangeHandler);
            c.Open();
            threadId = c.ServerThread;
            WeakReference wr = new WeakReference(c);

            Assert.True(wr.IsAlive);
            c = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Assert.False(wr.IsAlive);
            Assert.True(check.closed);

            MySqlCommand cmd = new MySqlCommand("KILL " + threadId, Connection);

            cmd.ExecuteNonQuery();
        }
Esempio n. 2
0
        public void ConnectionCloseByGC()
        {
            int threadId;
            ConnectionClosedCheck check = new ConnectionClosedCheck();

            MySqlConnectionStringBuilder connStr = new MySqlConnectionStringBuilder(Connection.ConnectionString);

            connStr.Pooling = false;
            MySqlConnection c = new MySqlConnection(connStr.GetConnectionString(true));

            c.StateChange += new StateChangeEventHandler(check.stateChangeHandler);
            c.Open();
            threadId = c.ServerThread;
            c        = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Assert.True(check.closed);
        }
Esempio n. 3
0
        public void ConnectionCloseByGC()
        {
            int threadId;
            ConnectionClosedCheck check = new ConnectionClosedCheck();
            string          connStr     = GetConnectionString(true) + ";pooling=true";
            MySqlConnection c           = new MySqlConnection(connStr);

            c.StateChange += new StateChangeEventHandler(check.stateChangeHandler);
            c.Open();
            threadId = c.ServerThread;
            c        = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Assert.IsTrue(check.closed);

            MySqlCommand cmd = new MySqlCommand("KILL " + threadId, conn);

            cmd.ExecuteNonQuery();
        }
    public void ConnectionCloseByGC()
    {
      int threadId;
      ConnectionClosedCheck check = new ConnectionClosedCheck();
      string connStr = GetConnectionString(true) + ";pooling=true";
      MySqlConnection c = new MySqlConnection(connStr);
      c.StateChange += new StateChangeEventHandler(check.stateChangeHandler);
      c.Open();
      threadId = c.ServerThread;
      c = null;
      GC.Collect();
      GC.WaitForPendingFinalizers();
      Assert.IsTrue(check.closed);

      MySqlCommand cmd = new MySqlCommand("KILL " + threadId, conn);
      cmd.ExecuteNonQuery();
    }