arya6000 0 Newbie Poster

Hello

I have the following code for a WPF application here is the code


Code from MainWindow.xaml.cs

public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
      Thread[] threads = new Thread[3];

      for (int i = 0; i < 3; i++)
      {
        int index = i;
        threads[i] = new Thread(new ThreadStart(test));
        threads[i].SetApartmentState(ApartmentState.STA);
        threads[i].IsBackground = true;
        threads[i].Start();
      }
    }

    public void test()
    {
      OutputWindow outputwindow = new OutputWindow();
      outputwindow.Show();
      System.Windows.Threading.Dispatcher.Run();

      outputwindow.textBox1.Text = "writing";
      //some more stuff done
      //some more stuff done
      //some more stuff done
      outputwindow.textBox1.Text = "\nmore writing";
      //some more stuff done
      //some more stuff done
      //some more stuff done
      outputwindow.textBox1.Text = "\nmore writing";
    }
  }

How can I make textBox1.Text actually get updated as test() is being executed?


Regards!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.