سلام.
من کد زیر رو تو backgroundworker نوشتم و خطا داد.میشه راهنمایی کنید که مشکل از کجاست
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while (backgroundWorker1.CancellationPending == false)
{
backgroundWorker1.ReportProgress(0);
System.Threading.Thread.Sleep(speed);
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
if (lbc.Text == "0")
{
if (panel1.Location.X > 4)
{
Point p = new Point();
p.X = panel1.Location.X - 5;
p.Y = panel1.Location.Y;
panel1.Location = p;
p.X = txtname.Location.X - 5;
p.Y = txtname.Location.Y;
txtname.Location = p;
p.X = lbname.Location.X - 5;
p.Y = lbname.Location.Y;
lbname.Location = p;
}
else
timer1.Enabled = false;
}
if (lbc.Text == "1")
{
if (panel2.Location.X > 4)
{
Point p = new Point();
p.X = panel2.Location.X - 2;
p.Y = panel2.Location.Y;
panel2.Location = p;
p.X = lbsq1.Location.X - 2;
p.Y = lbsq1.Location.Y;
lbsq1.Location = p;
p.X = txtsq1.Location.X - 2;
p.Y = txtsq1.Location.Y;
txtsq1.Location = p;
}
else
timer1.Enabled = false;
}
}
و خطای زیر رو داد
This BackgroundWorker states that it doesn't report progress. Modify WorkerReportsProgress to state that it does report progress.