Delegates/Messaging Uncoupling Threaded Applications

G

Guest

I currently have a .NET Form application which has a seperate thread invoking
delegates of the MainForm in order to have the main thread update the form's
controls.

I would like to move the secondary thread's behavior into another class, eg.
MyClass, but I would like MyClass to be completely uncoupled from the form,
so that it might be re-used in another application setting, eg. a service.

What is the .NET paradigm for "communicating" between objects, so that I
don't have to include, for instance, references to a delegate of a MainForm
method within MyClass? Or am I ignorant of some feature of the .NET delegate
paradigm?

Any help, or directions to reading, would be greatly appreciated.
 
J

Jon Skeet [C# MVP]

James Smyth said:
I currently have a .NET Form application which has a seperate thread invoking
delegates of the MainForm in order to have the main thread update the form's
controls.

I would like to move the secondary thread's behavior into another class, eg.
MyClass, but I would like MyClass to be completely uncoupled from the form,
so that it might be re-used in another application setting, eg. a service.

What is the .NET paradigm for "communicating" between objects, so that I
don't have to include, for instance, references to a delegate of a MainForm
method within MyClass? Or am I ignorant of some feature of the .NET delegate
paradigm?

Any help, or directions to reading, would be greatly appreciated.

Delegates don't need to be tied to any particular class. EventHandler
is a good example of this - any class can use it, any class can create
one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top