Winforms Application. Background thread retrieves messages from a MQ and makes changes on the UI Thread.
I need to call this method to Update a custom list
private void UpdateList()
{
if (ctrlLabel.IsHandleCreated)
{
ctrlLabel.Invoke(new Action(() =>
{
//Do Something
}
));
}
ctrlListView.Data = package;
//MARK
ctrlListView.Invoke(new Action(() =>
{
ctrlListView.LoadData();
}
));
//MARK
}
This method is invoked both times by the background thread. However, this works for the first call after the control is freshly instantiated.
On deleting items, when I try to refresh, this errors out with Null Exception Errors.
Interestingly, I was able to run this with some minor modification. I changed the [Control].Invoke to just Invoke, and it works(for the second call alone)
//MARK
Invoke(new Action(() =>
{
ctrlListView.LoadData();
}
));
//MARK
so, how does Invoke and [control].Invoke differ in operation?
Seen on Win7, .Net 4.0