Sunday, March 30, 2014

The Best Place For Loops?

You want to make an application wide resource - the data wich is regulary polled by a for loop and the for-loop itself should be a class instance that all forms share/is idependant of any form.

Unlike WPF, WinForms never got a proper support for Application wide varriables, so you have to create a fix with a static class:


http://ift.tt/1gd31Si


http://ift.tt/1gPTUwM


A more advanaced technique would be to have one non-static class for the data and the loop. Plus a second, static class that can hold multiple instances (each in a seperate field) of this data/loop class. That way you can have application wide resources without running into normal limitations of static.

There are otehr appraoches like Singleton Pattern or jsut relaying the isntance via the a overloaded Constructor.


Change Notification might be worth a look for this, as it simplyfies cases where you have many stakeholders in changes to a value/property:

http://ift.tt/KE9HyP




Let's talk about MVVM: http://ift.tt/1fpEgna Please mark post as helpfull and answers respectively.



No comments:

Post a Comment