Hi @OmkarHcl , Welcome to Microsoft Q&A.
I looked at the example you provided and it looks like you want to use toolStripProgressBar1 to complete the progress bar. You can simulate a progress bar moving. Use the PerformStep and timer controls that come with toolStripProgressBar1 to move the progress bar. Set an approximate long time, open the timer control at the beginning of the query, make the progress bar 100 at the end, and close the timer control.
private void timer1_Tick(object sender, EventArgs e)
{
if (toolStripProgressBar1. Value < toolStripProgressBar1. Maximum)
{
this.toolStripProgressBar1.PerformStep();
}
}
private async void button1_Click(object sender, EventArgs e)
{
timer1. Start();
timer1. Interval = 1000;
toolStripProgressBar1. Step = 2;
// Simulate a long query process
int totalRows = 100; // Suppose there are 100 rows in total in the query result
int rowsProcessed = 0;
await Task. Run(() =>
{
while (rowsProcessed < totalRows)
{
Thread.Sleep(500); // For demonstration purposes, use Thread.Sleep to simulate delays during queries
rowsProcessed += 10;
}
});
toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
timer1. Stop();
}
Set the appropriate step and interval according to your own needs.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.