i have a datagridview and it take times to load it datasource . i want to make a loading for it and i tried background workers and async await and task.factory.startnew and task.run and ... but when datagridview is filling my loading gif will be freezed.
what should i do?
i googled a lot and i saw a text. they said we have just one ui thread and when one is working another will be freezed is that correct? i have seen many post like this situation and i have tried them for 5 days but unsuccessful. maybe there is a clear thing that i cant see.
for example, it is like a situation that gif is loading and a richtextbox is filling: pictureBox1 will be freezed when we are in huge function
private void button1_Click (object sender, EventArgs e)
{
Task.Factory.StartNew(()=>;
{
huge();
}
);
}
private void huge()
{
richTextBox1.Invoke(new EventHandler(delegate
{
for (int i = 0; i < 10000; i++)
{
richTextBox1.Text += "s";
}
}));
pictureBox1.Visible = false;
}