Threads debugging

L

Lubomir

Hi,

I have the folloving code:

Public class MyForm : Form
{
……
void SomeMethod()
{
a = new Obj1(this);
Thread t = new Thread( new ThreadStart( a.CallMethod ) );
t.Start();
}
}


Class Obj1
{
Public Obj1(Form myForm)
{
parent = myForm;
}


Public void CallMethod()
{
…
if (parent != null) //// so far debugging is OK
{
Do something
}

Process.Start(...) //Run a process (external exe file)
....
if (parent != null) //// => Debugger will hang
{
Do something
}
}

The debugger will either hang out on the second occurence of "if (parent !=
null)" or sometimes it seems like it goes through but doesn't stop on any
futher break point. When I run it wthout a debugger, everything is OK.

I am debugging form a Vista 64 bit machine, and application (32 bits) is
running on virtual machine VMWare, Vista 32. I am attaching debugger to the
process while debugging.

Why I can not debugging it?

Thanks,
Lubomir
 
P

parez

Hi,

I have the folloving code:

Public class MyForm : Form
{
……
void SomeMethod()
{
a = new Obj1(this);
Thread t = new Thread( new ThreadStart( a.CallMethod ) );
t.Start();
}

}

Class Obj1
{
Public Obj1(Form myForm)
{
parent = myForm;
}

Public void CallMethod()
{

if (parent != null) //// so far debugging is OK
{
Do something
}

Process.Start(...) //Run a process (external exe file)
....
if (parent != null) //// => Debugger will hang
{
Do something
}

}

The debugger will either hang out on the second occurence of "if (parent !=
null)" or sometimes it seems like it goes through but doesn't stop on any
futher break point. When I run it wthout a debugger, everything is OK.

I am debugging form a Vista 64 bit machine, and application (32 bits) is
running on virtual machine VMWare, Vista 32. I am attaching debugger to the
process while debugging.

Why I can not debugging it?

Thanks,
Lubomir


I think when you try to access the form from a different thread , it
does not like it...

try this
MyForm .CheckForIllegalCrossThreadCalls=false;

to see if that is the probelm..
 
L

Lubomir

parez said:
I think when you try to access the form from a different thread , it
does not like it...

try this
MyForm .CheckForIllegalCrossThreadCalls=false;

to see if that is the probelm..

It is the same even when I pass null instead of "this".
 
C

Ciaran O''Donnell

Could you provide details of the process start call. Are you redirecting
output or anthing that will stop the process finishing. Maybe that is the
cause of the hang
 

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