Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i'm using the
C#
progress bar
in my application.
C#
thread
download the data from database and it's convert into table. when thread finish the work that table will download.
i have an issue in download table from thread process.

how to get the output from the thread


C#
protected void btnStart_Click(object sender, EventArgs e)
   {
       StringBuilder threadBuilder = new StringBuilder();
       ProgressBar1.Visible = true;
       pReadytoDown.Visible = true;
       Progress progress = ProgressBar1.Progress;
       Thread thread = new Thread(() => { threadBuilder = Start(progress);
      <big> _builder</big> = threadBuilder;

       });
       thread.Start();
       btnStart.Enabled = false;

       //ProgressBar1.Completed = false;
   }

i'm used the global static variable to solve this problem

thank you
Posted
Updated 23-Mar-15 23:19pm
v5
Comments
Tomas Takac 24-Mar-15 3:48am    
Show your code and use it to explain where you are stuck.
Sinisa Hajnal 24-Mar-15 4:55am    
There are thread events that you can subscribe to. Google a bit, you'll find it.
F-ES Sitecore 24-Mar-15 5:24am    
You can't send things to the client from a background thread.

1 solution

C#
protected void btnStart_Click(object sender, EventArgs e)
   {
       StringBuilder threadBuilder = new StringBuilder();
       ProgressBar1.Visible = true;
       pReadytoDown.Visible = true;
       Progress progress = ProgressBar1.Progress;
       Thread thread = new Thread(() = { threadBuilder= Start(progress);
       _builder = threadBuilder;

       });
       thread.Start();
       btnStart.Enabled = false;

       //ProgressBar1.Completed = false;
   }


answer is in ques.
return the value from the thread focusing method simple.
threadBuilder is the return value
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900