How to update UI controls(ex. list box) from another thread in ASP.NET? From the below code I am expecting to update listbox once performLongTask1() and performLongTask2() completes execution and also should update in the order of finishing task.
- protected void Button1_Click(object sender, EventArgs e)
- {
- Thread t1 = new Thread(performLongTask1);
- Thread t2 = new Thread(performLongTask2);
- t1.Start();
- t2.Start();
- ListBox1.Items.Add("LongTask1 Started");
- ListBox1.Items.Add("LongTask2 Started");
- }
- private void performLongTask1()
- {
- Thread.Sleep(5000);
- //ListBox1.Items.Add("LongTask1 Completed");
- }
- private void performLongTask2()
- {
- Thread.Sleep(10000);
- //ListBox1.Items.Add("LongTask2 Completed");
- }


Dinesh GabhaneRank #265 · 9.5K reputationPosted Oct 9, 2019, 8:43 PM EDT
Pradeep SRank #2,740 · 511 reputationPosted Oct 12, 2019, 6:10 AM EDT
Dinesh GabhaneRank #265 · 9.5K reputationPosted Oct 12, 2019, 6:13 AM EDT