Can I do something similar in a Windows Forms application?
I am trying to find other ways to update the user interface, rather than using BackgroundWorker all the time. Maybe something like this ?:
public List<String> results = new List<String>();
private void button1_Click(object sender, EventArgs e)
{
When(SomeLongRunningMethod("get") == true)
{
foreach(string result in results)
{
this.Controls.Add(new Label() { Text = result; Location = new Point(5, (5 * DateTime.Now.Millisecond)); });
}
}
}
public void SomeLongRunningMethod(string value)
{
if(value == "get")
{
results.Add("blah");
}
}
It basically says, "Do it, and when you're done, add the results to the form."
source
share