The problem is that UI hanging. Below the code.
private void Button1_Click(object sender, EventArgs e)
{
Thread childThread = new Thread(getlistAsync);
childThread.Start();
}
private void getlistAsync()
{
while (true)
{
add("a", "b", "c", "d");
}
}
public async Task add(string prob, string reg, string data, string user) //async task
{
String[] row = { prob, reg, data, user };
ListViewItem item = new ListViewItem(row);
this.listView1.BeginInvoke(
new Action(() =>
{
listView1.Items.Add(item);
listView1.Refresh();
}));
}
private void Form1_Shown(object sender, EventArgs e) //on shown
{
listView1.Columns.Add("Problems", 80);
listView1.Columns.Add("Data", 120);
listView1.Columns.Add("Registry Key", 130);
listView1.Columns.Add("users", 80);
}