[Solved] Add controls to a StackPanel in a BackgroundWorker or async Task called from another BackgroundWorker


You cannot create controls from any thread except for the UI thread.

To run code on the UI thread you can use Dispatcher.BeginInvoke, you can find the dispatcher on any UI element (in the Dispatcher property) or using the statis Dispatcher.CurrentDispatcher property from the UI thread before starting the background process.

solved Add controls to a StackPanel in a BackgroundWorker or async Task called from another BackgroundWorker