0

I have a wpf app that has multiple sockets open to various hosts. The hosts will be intermittently sending packets and I will occasionally have to send packets to the hosts. I have the app working where the socket threads dispatch calls to the ui thread to display data. The app is growing to where it will have multiple UI "widgets/controls" where multiple widgets may display data (different renderings) from a single socket. It would be nice to have some observablecollections that exist on the UI thread. And the sockets send weak events to the UI thread. The ui thread updates the collections and ,voila, the widgets update. To send from the UI to the socket, perhaps have a stream with synchronized access?

Does anyone have any good suggestions on a design that would make this a maintainable app?

tim
  • 1,371
  • 3
  • 19
  • 30

1 Answers1

0

The MVVM pattern works well for interfacing between UI and lower level logic. There are many tutorials and examples on how to get started with MVVM (see this post). Additionally there have been frameworks developed to assist you in adopting the MVVM pattern such as MVVMLight.

A quick overview would be something like this:

  1. Your View displays the UI to your user
  2. The View is bound to the ViewModel which prepares data for display and marshals threads accordingly
  3. The ViewModel interacts with your Model which stores your backing data and manages your sockets
Community
  • 1
  • 1
Dan Busha
  • 3,723
  • 28
  • 36