G
Guest
Hi,
I have a tough problem in a Windows Form app. It uses the background worker
object to do some, well, background work. I need this because I want this
worker to be feeding a listbox logging its progress. I am using the correct
protocol to deal with interthread call from the worker to the listbox, ie.:
--------
private void AddLineOfInfo( string info )
{
this.txtProgress.Text += info;
}
private delegate void ClearInfo();
private void AddThisInfo( string info )
{
Invoke( new SetInfo( this.AddLineOfInfo), new object[] { info } );
}
-----------------
So I only directly call AddThisInfo. This seems to work fine. However, I
need to access this method from an object created in the background worker
thread. So I thought I would pass 'this' as a parameter to this new object's
constructor. 'this' is a form...and I think the problem starts here!
When I invokee the constructor of this new object passing 'this', the
debugger becomes sort of frozen for a bit and then finally when it allows me
to Break All, the worker thread seems blocked -- no action whatsoever.
All in all, the app freezes and I am forced to Stop Debugging.
My theory is that one thread is having difficulty accessing the form on the
other thread. The exact explanation is what I lack!!
Any insight?
I have a tough problem in a Windows Form app. It uses the background worker
object to do some, well, background work. I need this because I want this
worker to be feeding a listbox logging its progress. I am using the correct
protocol to deal with interthread call from the worker to the listbox, ie.:
--------
private void AddLineOfInfo( string info )
{
this.txtProgress.Text += info;
}
private delegate void ClearInfo();
private void AddThisInfo( string info )
{
Invoke( new SetInfo( this.AddLineOfInfo), new object[] { info } );
}
-----------------
So I only directly call AddThisInfo. This seems to work fine. However, I
need to access this method from an object created in the background worker
thread. So I thought I would pass 'this' as a parameter to this new object's
constructor. 'this' is a form...and I think the problem starts here!
When I invokee the constructor of this new object passing 'this', the
debugger becomes sort of frozen for a bit and then finally when it allows me
to Break All, the worker thread seems blocked -- no action whatsoever.
All in all, the app freezes and I am forced to Stop Debugging.
My theory is that one thread is having difficulty accessing the form on the
other thread. The exact explanation is what I lack!!
Any insight?