المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : My issue is regarding handling multiple backgroud worker and multiple progressbar



C# Programming
03-28-2013, 03:45 PM
my main problem is when i add dynamically a progressbar on flowLayoutPanel1 for each request then how can i increase right progressbar value frombackgroundWorker1_ProgressChanged event

when user click on start button then i will call RunWorkerAsync function of background worker....it is fine. here i am writing a sample code and try to show my problem.

my form has one textbox, one button and one flowLayoutPanel1 with FlowDirection topdown.

when user enter any url in textbox and click on start button then i will start file download with BackGroundWorker and add one progress bar dynamically on flowLayoutPanel1. 10 file can be downloaded at a time. so when user enter ten url one after after one and click on submit button then ten file will be downloading in background.

my problem is how to increment 10 progress bar progress properly from backgroundWorker1_ProgressChanged event another issue is when any file download will complete then the progress bar for which it has been created will be removed from panel

here is my full code. please have a look and tell me what i need to do to achieve my task. if anyone see there is problem in my code for which a dead lock may appear then also please guide me how to avoid dead lock. here is my code

public partial class Form1 : Form { static int pbCounter = 1; public Form1() { InitializeComponent(); } private void btnStart_Click(object sender, EventArgs e) { ProgressBar pb = new ProgressBar(); if (pbCounter