Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am created a long process in a thread ....like this

private void task1()
{
//a long process i don't know when this process end. 
}


on button click________________________________________
Thread longprocess = new Thread(task1);
                longprocess.IsBackground = true;
                longprocess.Start();



How can i set a progress bar for this thread......
Posted

Hi,

Instead of a Thread, use a BackgroundWorker:
http://www.dotnetperls.com/backgroundworker[^]
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx[^]
If you added a BackgroundWorker, you can use a ProgressBar:
http://www.dotnetperls.com/progressbar[^]
 
Share this answer
 
Check this link. It will be helpful for you. Link : http://bytes.com/topic/c-sharp/answers/566571-changing-progressbar-seperate-thread[^]
 
Share this answer
 
Hi,

you can try this :

C#
/// <summary>
///   Update the work item state counts.
/// </summary>
private void RefreshCounts()
{
    if (this.InvokeRequired)
    {
        MethodInvoker mi = new MethodInvoker(RefreshCounts);
        this.BeginInvoke(mi);
    }
    else
    {
        lock (this)
        {
            progressBar1.Value = ProgressDownload;
        }
    }


}



godd luck

jeremy
 
Share this answer
 
Try this JQuery Progress Bar....:)





HTML
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Progressbar - Default functionality</title>
  
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  
  <script>
  $(function() {
    $( "#progressbar" ).progressbar({
      value: 37
    });
  });
  </script>
</head>
<body>
 
<div id="progressbar">

</div>
 
 
</body>
</html>
 
Share this answer
 
v2
Comments
satheeshk787 27-Jun-13 7:10am    
not for web, for windows application

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