471,325 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Threads debugging

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
Jun 27 '08 #1
3 1261
On Apr 24, 12:59 pm, Lubomir <Lubo...@discussions.microsoft.com>
wrote:
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..
Jun 27 '08 #2
"parez" wrote:
On Apr 24, 12:59 pm, Lubomir <Lubo...@discussions.microsoft.com>
wrote:
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..
It is the same even when I pass null instead of "this".

Jun 27 '08 #3
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
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Lubomir" wrote:
"parez" wrote:
On Apr 24, 12:59 pm, Lubomir <Lubo...@discussions.microsoft.com>
wrote:
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..

It is the same even when I pass null instead of "this".
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by John Wood | last post: by
6 posts views Thread by BogusException | last post: by
35 posts views Thread by Carl J. Van Arsdall | last post: by
2 posts views Thread by sunil | last post: by
5 posts views Thread by tshad | last post: by
3 posts views Thread by =?Utf-8?B?cm9iaW50dw==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.