I’m using a Dispatcher to update my UI before I handle some resiszing.
The Problem ist the part of BeginInvoke(DispatcherPriorty, new ACTION) is where I am stuck.
I want to call a method with Parameters and I don”t know why.
Thats my current Dispatcher:
void s_SizeChanged(object sender, SizeChangedEventArgs e)
{
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(test));
}
And this is my method i am calling:
public void test()
{
foreach (Structures s in ((TreeView)this.cont.Children[0]).Items)
s.updateRelationLines(this.Data, this.cont.ColumnDefinitions[1]);
}
I just want to replace this.Data and this.cont.Columndefinitions[1] with Parameters.
You can use a lambda expression for this:
This basically creates an anonymous method
and invokes this method through the dispatcher. Some compiler magic ensures that param1 and param2 are available to this method, even if they are only in the scope of your
s_SizeChangedmethod. More details on this can be found here: