Question

I have a WPF application, which requires use of NetworkAvailablityChanged to determine when a user has changed from disconnected from the network. However, I am developing my application using the MVVM pattern. So I'm not quite sure how to use this to where it will begin monitoring as soon as the application has started. Any advice on the best way to implement this or perhaps a better way to monitor all of the computer's network interfaces?

Update: From my understanding of MVVM, the Model interacts with the data. In this case, the data would be what is returned when the connection to the active network interface changes. However, if I put this in the model I do not know of a way to make it start monitoring when the application starts. Simply, I need to create a method that monitors the network interfaces and returns whether the current active interface is an Ethernet interface, 802.11 Wireless interface, or if there is no connection at all. Then based on that I'll call the proper property in my model.

Was it helpful?

Solution

Sometimes purity of architecture interferes with simplicity of design. This sounds like one of those cases.

Continue to use MVVM to structure your application's work and data flow. However temporal indicators (like network availability) and error conditions (like out of disk space) don't cleanly fit into these models and are best deal with independently.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top