Can I safely bind to data on multi-threaded applications?

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-05-20T14:08:31Z Indexed on 2010/05/20 14:10 UTC
Read the original article Hit count: 188

Filed under:
|
|

Hi everyone,

I'm trying to solve a classic problem - I have a multi-threaded application which runs some processor-intensive calculations, with a GUI interface.

Every time one of the threads has completed a task, I'd like to update a status on a table

taskID | status

I use DataGridView and BindingList in the following way:

BindingList<Task> tasks;
dataGridView.DataSource = tasks

public class Task : INotifyPropertyChanged
{
    ID{get;}
    Status{get;set;}
}

Can a background thread safely update a task's status? and changes will be seen in the correct order in the GUI?

Second Question: When do I need to call to PropertyChanged? I tried running with and without the call, didn't seem to bother..

Third Question: I've seen on MSDN that dataGridView uses BindingSource as a mediator between DataGridView.DataSource and BindingList Is this really necessary?

© Stack Overflow or respective owner

Related posts about c#

Related posts about databinding