开发者

Winforms DataGridView UI does not update

开发者 https://www.devze.com 2023-03-11 08:40 出处:网络
I am working on a application which downloads using 1) Parallel.ForEach(linklist, x => DownloadAsync(x));

I am working on a application which downloads using

1) Parallel.ForEach(linklist, x => DownloadAsync(x)); 
2) webClient.DownloadStringAsync(new Uri(link.Url));  

class Link 
{
 string url;
 string result;
 int progress;
}

and updates the datagridview using INotifyPropertyChanged.

The problem is that the download is real fast, the datagridview updates first row, then the UI does not update, but then on moving the mouse cursor on da开发者_开发知识库tagridview rows one by one each row updates values.

I don't understand where I am missing anything.

please any suggestings, thank you in advance.

EDIT: Async does not block the GUI, so i am not using background thread.


Although you don't show your code, I assume you are updating UI elements from backgroud thread, which is something you should never do. If you are targeting WinForms you need to use BackgroundWorker or Control.Invoke.

BackgroundWorker Component Overview
How to: Implement a Form That Uses a Background Operation
How can I update my user interface from a thread that did not create it?


Your objects, being bound, need to implement INotifyPropertyChanged.

0

精彩评论

暂无评论...
验证码 换一张
取 消