i get this error when trying this:
ERROR method name expected.
How should i do to correct the problem
delegate void DelegateFillList(DeliveryDoc[] deliveryDocs);
private void FillListViewAssignment(DeliveryDoc[] docs) {
if(lvMyAssignments.Dispatcher.CheckAccess()) {
lvMyAssignments.ItemsSource = docs;
lvAllOngoingAssignments.ItemsSource = docs;
if(m_tempDeliveryDocs != null) {
txtblockHandOverCount.Text = m_tempDeliveryDocs.Length.ToString();
}
} else {
lvMyAssignments.Dispatcher.BeginInvoke(
new DelegateFillList(FillListViewAssignment(docs)), null);
}
}
This is the problem:
new DelegateFillList(FillListViewAssignment(docs)
You can't create a delegate that way. You need to provide a method group which is just the name of the method:
lvMyAssignments.Dispatcher.BeginInvoke
(new DelegateFillList(FillListViewAssignment), new object[]{docs});
Alternatively, you could do it in two statements:
DelegateFillList fillList = FillListViewAssignment;
lvMyAssignments.Dispatcher.BeginInvoke(fillList, new object[]{docs});
The reason for the extra "wrapping" array is that you've only got one argument, which is an array - you don't want it to try to interpret that as a bunch of different arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With