I have a loop:
List<FrameworkElement> list;
public void Foo(object sender, PrintPageEventArgs e)
{
foreach(FrameworkElement fe in list)
{
fe.LayoutUpdated += FeLayoutUpdated;
fe.UpdateLayout();
}
if(counter >= lista.Count)
e.PageVisual = objectFromClass. // was DoSth()
}
int counter = 0;
void FeLayoutUpdated(object sender, EventArgs e)
{
counter++
}
So I need DoSth() to be fired always when Foo() is fired and when all FrameworkElement objects from list will have it's Layout updated. I was trying to use some Thread class and also BackgroundWorker, but I couldn't reach desired behaviour, which is that main Thread is waiting for fe.UpdateLayout's to finish their jobs. I hope I made the main idea clear. Thanks for replies.