Very strange result when I set breakpoint in DoWork event handler

G

Guest

When I set breakpoint in worker_DoWork,I cannot debug it step by step.For
example, I set breakpoint at System.Threading.Thread.Sleep(20); Then run the
program,it'll break at this statement.At this time,pressing F11,it shoud
move to next statement,but it doesn't.I don't know where the program go to.If
I clear
the breakpoint,everything works very well. I am using VS2005 and testing it
in win2000,XP in my two notebooks(Samsung x10 and HP tc1100).Following is
part of my code:
public partial class Form1 : Form
{
private BackgroundWorker worker;
public Form1()
{
InitializeComponent();
worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.ProgressChanged += new
ProgressChangedEventHandler(worker_ProgressChanged);
}

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
label1.Text = e.ProgressPercentage.ToString();
}

void worker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker wk = (BackgroundWorker) sender;
for (int i = 0; i < 1000; i++)
{
wk.ReportProgress(i);
System.Threading.Thread.Sleep(20);
if (wk.CancellationPending)
{
e.Cancel = true;
return;
}
}


}

private void button1_Click(object sender, EventArgs e)
{
worker.RunWorkerAsync();

}
}

Anybody can give me some advice?By the way,I ask my friends to test it in
desktop,they haven't encounter this problem.
Thanks in advance

wyghf
 
G

Guest

After so many test and try,I solve this problem by myself. If you close local
variable
,auto variable debug window,everything is ok.
wyghf
 
T

TJO

In case anyone else ever views this thread and are not sure what is
meant by "close local variable' he means for you to close the locals
window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top