How to show WPF controls during run script
Options
Hello!
I wrote following code
foreach(var item in names) { var button = new System.Windows.Controls.Button { Content = item }; button.Click += (sender, args) => button.Content = "I've just been clicked!"; PanelManager.StackWpfElement(button); while( ...smth... ) Thread.Sleep(100); }
I wait for that code show button and wait my click to continue, but show nothing. if I remove while with sleep then I show all buttons at once. How to show WPF controls during run script?
Comments
-
Replace the call to Thread.Sleep with:
await Task.Delay(1000);
Another option, if you need just a simple button and not a WPF button, is to use LINQPad's HTML controls, i.e., LINQPad.Controls.Button:
var button = new LINQPad.Controls.Button ("test") { IsMultithreaded = true }; button.Click += (sender, args) => button.Text = "I've just been clicked!"; button.Dump(); Thread.Sleep(1000);