Debugging Windows Application with Threads

T

tshad

I am having an issue with debugging threads.

When I press a button, I typically run my process in a thread:
*************************************************
private void btnReProcess_Click(object sender, EventArgs e)
{
Thread oThread = new Thread(new ThreadStart(ReProcessThread));
oThread.Start();
}

private void ReProcessThread()
{
disableButtons();
Maintenance.MoveFiles( this);
enableButtons(true);
}
********************************************************

If I put a breakpoint on the Maintenance.MoveFiles function, the system
seems to freeze for about 20 seconds when it gets to the breakpoint. If I
press the "Step Into" button, the form comes up again and won't continue
until I push the button again. It then goes to the breakpoint again. Then
it normally will continue on and I can step through it. But not always.

The main thread is not doing anything while this is going on (which is why I
put the disableButtons() function there - to prevent that).

Why doesn't the program continue on when I try to step through the first
time?

Thanks,

Tom
 
P

Peter Duniho

[...]
If I put a breakpoint on the Maintenance.MoveFiles function, the system
seems to freeze for about 20 seconds when it gets to the breakpoint. If
I
press the "Step Into" button, the form comes up again and won't continue
until I push the button again. It then goes to the breakpoint again.
Then
it normally will continue on and I can step through it. But not always.

Where is your concise-but-complete code example that reliably reproduces
the problem?
The main thread is not doing anything while this is going on (which is
why I
put the disableButtons() function there - to prevent that).

What does the "disableButtons()" method do? If it's actually accessing
your GUI objects (e.g. setting a Button instance's Enabled property to
"false"), then that's a very bad thing to do on a different thread from
the main GUI thread. Likewise the "enableButtons()" method.
Why doesn't the program continue on when I try to step through the first
time?

No possible way to know without a concise-but-complete code example.

Pete
 

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