I am trying to figure out how I can update my UI from an DLL that is doing some task.
I cant figure out how the DLL can know anything of the UI.
To hopefully explain more clear:
I have let’s say task1, task2 and UI.
task1 and task2 are both DLL’s and dont know anything of UI.
How can I tell the DLL’s to call some function in UI?
Hopefully I am clear enough, my knowledge of C# is far from where I want it to be.
Thanks in advance.
PS to hopefully not make it worse both tasks have their own appDomain’s
You don’t tell them to update the UI, you raise an event that indicates something has changed, that might be interesting – you then make the UI subscribe to that event on your instances, and update the UI accordingly.
So, let’s say you want to raise an event whenever any of the properties on a class change (conveniently, there is the
INotifyPropertyChangedinterface that even describes that you are going to do this, and a lot of things will “notice” and “do the right thing”, such asBindingList<T>)So you declare that your class has properties:
Then, to raise the event, you simply call:
To subscribe to the events (in your client application/UI layer) it’s as simple as having your event hadler:
Add wiring up