J
James Salter
Hi,
I have been using Control.Invoke() extensively on a project in order to
pass information from various worker threads to the interface thread.
Most of my worker objects hide this functionality by raising events that
are garuanteed to be fired in the constructing thread, by instantiating
a protected Control in the constructor and using it with Invoke later
on, to call delegates and then raise the events.
This is nice in the sense that it hides everything from the caller, and
is truly an encapsulated solution, but as I get more and more of these
worker threads I am starting to become concerned about the footprint of
these invisible Controls.
The alternatives to doing it this way are, get the caller to pass a
Control to the object (which might be inconvenient, and exposes the
internals somewhat), or maintain a static reference to the applications
main form somewhere. The latter solution is attractive, but i can't
figure out how to implement it without the client having to set the main
form themselves, which seems like a bad way of doing things.
What is the general convention for solving this problem?
James
I have been using Control.Invoke() extensively on a project in order to
pass information from various worker threads to the interface thread.
Most of my worker objects hide this functionality by raising events that
are garuanteed to be fired in the constructing thread, by instantiating
a protected Control in the constructor and using it with Invoke later
on, to call delegates and then raise the events.
This is nice in the sense that it hides everything from the caller, and
is truly an encapsulated solution, but as I get more and more of these
worker threads I am starting to become concerned about the footprint of
these invisible Controls.
The alternatives to doing it this way are, get the caller to pass a
Control to the object (which might be inconvenient, and exposes the
internals somewhat), or maintain a static reference to the applications
main form somewhere. The latter solution is attractive, but i can't
figure out how to implement it without the client having to set the main
form themselves, which seems like a bad way of doing things.
What is the general convention for solving this problem?
James