Question: In C I could write a plugin by having a shared library implement the following interface:

```
extern "C" int initialize(SomeArgument * state);
extern "C" int shutdown(SomeArgument * state);

```

Obviously this is a *very* high level interface, but I think it gets the point across. I've heard that a good use of reflection is to write plugins, but why would that be superior to what I have here? Using an interface like this gives the following advantages:

* faster (reflection isn't fast, both looking up methods and calling indirectly)
* memory (reflection has memory overhead)
* straight-forward (entry/exit points for the plugin are intuitively obvious)

Am I just missing something?

Answer: 
Use this subscription:

```
TheListBox.ItemContainerGenerator.StatusChanged += (sender, e) =>
{
  TheListBox.Dispatcher.Invoke(() =>
  {
     var TheOne = TheListBox.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
       if (TheOne != null)
         // Use The One
  });
};

```
In my case `grid.UpdateLayout();` didn't help an I needed a `DoEvents()` instead:

```
    DataGridRow row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);

    if (row == null)
    {

        WPFTools.DoEvents();

        grid.ScrollIntoView(grid.Items[index]);
        row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
    }

    /// <summary>
    /// WPF DoEvents
    /// Source: https://stackoverflow.com/a/11899439/1574221
    /// </summary>
    public static void DoEvents()
    {
        var frame = new DispatcherFrame();

        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
            new DispatcherOperationCallback(
                delegate (object f)
                {
                    ((DispatcherFrame)f).Continue = false;
                    return null;
                }), frame);

        Dispatcher.PushFrame(frame);
    }

```