2

I've been struggling to find efficient solution to get live data from MySQL database to datagridview. In my database values are changing every second or even faster. I need to get live feed directly to my windows app. The only solution I could found is to use async, but then app get laggy when trying to move it arround or do other tasks. My attempt:

public async void refreshOutput()
    {

        while (true)
        {
            DataTable dbResults = Connect_ToDB.executeQuery("SELECT * FROM mysql.test_table;");
            dataGridView2.DataSource = dbResults;
            await Task.Delay(200);
        }

    }

Also I tried:

    private void button24_Click(object sender, EventArgs e)
    {
        DataTable data = Connect_ToDB.executeQuery("SELECT * FROM mysql.test_table;");

        BindingSource bSource = new BindingSource();
        bSource.DataSource = data;

        dataGridView2.DataSource = bSource;


    }

In any case i always need to push the button again to get new data. Is there a way to get it live without disturbing the application background processes? Thank you!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vyt Autas
  • 61
  • 1
  • 7
  • https://stackoverflow.com/questions/44185298/update-datagridview-very-frequently This may be useful – Tim Oct 24 '18 at 15:05
  • Did not helped using double buffer. App is still lagging when refreshing. Is there any way to get simply live stream to datagrid without even refreshing it?? – Vyt Autas Oct 25 '18 at 07:18

0 Answers0