Suppose there is a Console Application, which prints text into command window. Also there is the Logger WPF window, which has to duplicate output. IDE forces me to create window inside new thread (STA):
public SomeClass()
{
    var loggerThread = new Thread(() =>
    {
        var logWindow = new Window
        {
            Title = "Logger", Width = 100, Height = 100
        };
        var stackPanel = new StackPanel 
        {
            Name = "stackPanel"
        };
        stackPanel.Children.Add(new TextBlock 
        {
            Name = "textBlock", Text = "new text\n"
        });
        logWindow.Content = stackPanel;
        logWindow.ShowDialog();
    });
    loggerThread.SetApartmentState(ApartmentState.STA);
    loggerThread.IsBackground = true;
    loggerThread.Start();
}
public void PutInfo(string msg)
{
    // how to access textBlock here?
    ...textBlock.Text = "some info";
}
How can I access textBlock.Text after the thread is started. In other words, how to access UI elements in that thread from another classes through PutInfo() method?
 
     
    