-1

Simple question, I had an application in console mode. Every thing would write in the console using Console.WriteLine. However, now I have a form and a listbox. I know easily how to do it, however, what is the proper way to do it?

Cher
  • 2,609
  • 7
  • 32
  • 60

1 Answers1

1

You can access the UI from another thread using delegate, simple and neat:

 this.Invoke((MethodInvoker)delegate
            {
                textBox1.Value = "your text";
            });
NicoRiff
  • 4,729
  • 2
  • 27
  • 53
  • thanks a lot for you answer. Can you tell me where I go wrong? Here is my code : this.Invoke((MethodInvoker)delegate { lstStatus.Items.Add("test"); }); – Cher Jan 21 '17 at 22:04