c# - what pattern should I use to couple .NET UI to a .NET library class that will provide callback updates -
Should I use the best approach / pattern for the following?
- A C # UI solution will be (A) Winforms / WPF UI, and (B) Class Library.
- The UI must start a different thread for the regular in the class library which will be voted Class Library then needs to trigger a callback function in the UI to update UI areas
How do I apply this callback system best so that classroom library is reused, and ideally it should not have any dependency on the UI component.
Thanks
You can do this through an event raised from your library. In this way, the library will only need to pop up the event, if the UI takes the option to consume this phenomenon then implementation in the UI is implemented.
You can also expose a property such as callback method and a representative who accepts it, then in the UI, you set the property to the address of your function when the "Send required callback" ", You check to see if the callback is populated, call the callback function (through the representative), if it is set, or leave it, if it Is not
Comments
Post a Comment