Murali Kris

Murali Kris

  • 1.5k
  • 254
  • 48k

how to use progress bar for custom code..

Nov 19 2018 3:53 AM
Hi,
 
As of now with below script i can able to get my data as expected.
 
1. Connecting server(site).
2. Getting some content(site content).
 
a: Here calling another method for get site content and display gridview
b:using threading for UI Freez(UI Responcive).
 
please find below button_1 code
 
private void button1_Click(object sender, EventArgs e)
{
Thread threadcall = new Thread(() =>
{
lists(); // this is calling function to get site contents
Action action = new Action(finalsms);
this.BeginInvoke(action);
});
threadcall.Start();
label10.Text = "Loading lists please wait...";
}
private String lists() // function here for get site contents
{
//my custom script for load site content
foreach (var list in coll)
{
var dr = dt.NewRow();
dr["List Names"] = list.Title;
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
return string.Empty;
}
as of now i can able to get as expted output. but i want to add progress bar to show background process status on progress bar.
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
// what code i need do add here if list finction i need to add,
//if list() function code , yes i tryied alredy but no luck.
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{// what is the code that i need to add here
}

Answers (3)