Accessing Form Controls From Threaded Delegate via Async Callbacks.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Form that hosts a control (used for visual
feedback).
From this form a Class is created.
This Class has several events/delegates that are triggered
by a Socket (which is a member of the class)'s Async
Callbacks. [Eg OnConnected, etc ].
From within this delegate eg. OnConnected, OnReceivedData
and OnClose I need a way to be able to provide visual
feedback to the form.

I setup an event/delegate on the Form and made it public
so others could access it. A refernece to the Form was
passed to the Class when it was created.
However the minute i call Parent.Invoke
(Parent.VisualMethod,......) the program hangs. Trapped
inside a Try catch to catch any exceptions the program
just hangs. I've stepped through the code and when I step
into that line the program and debugger never come back.

I've tried Control.Invoke, new DelegateMethod(parameters),
Parent.VisualControl.Methodstoupdate

Maybe there is something here I dont quite fully
understand. Maybe there is something very simple that I'm
missing. Or Maybe there is an alternate method of
achieving my goal.
 
Whoops. Turns out that the Sleeping thread in the Main
Form was what was killing me. Stuck everything in its own
thread and everything is working just peachy .
 
Back
Top