S
Stephen Brooker
Hi all,
I've got a basic TCP app that is giving me trouble. I have a separate
class that takes care of the TCP connection, and uses the NetworkStreams
BeginRead and EndRead with a callback function to deal with the server
response. All works well and the data is received OK. Once all the data
is received, the connection is closed and I fire an event indicating all
is finished. The event is handled in the main form of the application
and I can work with the returned data OK.
The problem arises when I try to add some of the data to a TreeView. It
complains that only the creating thread can modify the TreeViews data
and I should use BeginInvoke etc (all this so far I understand). So I
assume control is still with the thread created by BeginRead? Am I
correct? If so, is there any way of forcing control to return to the
main forms threads once the event is fired for the data being received?
I've been able to set values on several other controls, the TreeView is
the only one giving me problems (why is it so picky when none of the
other controls are).
TIA
Steve.
I've got a basic TCP app that is giving me trouble. I have a separate
class that takes care of the TCP connection, and uses the NetworkStreams
BeginRead and EndRead with a callback function to deal with the server
response. All works well and the data is received OK. Once all the data
is received, the connection is closed and I fire an event indicating all
is finished. The event is handled in the main form of the application
and I can work with the returned data OK.
The problem arises when I try to add some of the data to a TreeView. It
complains that only the creating thread can modify the TreeViews data
and I should use BeginInvoke etc (all this so far I understand). So I
assume control is still with the thread created by BeginRead? Am I
correct? If so, is there any way of forcing control to return to the
main forms threads once the event is fired for the data being received?
I've been able to set values on several other controls, the TreeView is
the only one giving me problems (why is it so picky when none of the
other controls are).
TIA
Steve.