[Closed] dotNet timer scope within structs
You might also want to check out the System.IO.FileSystemWatcher class, which allows you to monitor file/folder changes. I’ve attached a simple example.
Cheers,
Martijn
Thanks for posting this martijn, I have been meaning to take a look at this class for a while! cheers!
p.s. seems to work fine for me dave, whatcha doin?
Hey, that rocks! Or at least it rocked for about 2 files, then it stopped working and now it won’t start again :surprised
That’s tidied it up very nicely … glad the passing technique helped … and then magicm comes along and cuts the Gordian Knot! But for general purposes, it might still be useful to be able to ping struct instance methods.
One thing that struck me … way too many timers hanging around. They’re not cheap. If you’re monitoring lots of things, they shouldn’t have to have one timer each. It would be nice to bring both sides of the observer pattern into MXS. One timer pinging one ‘raise event’ function, which then calls its personal array of instance methods. It would be a doddle in some languages, but a fair amount of faffing around hasn’t got me very far, in my bad MXS. Things like looking for existing functions in the array, to check against duplication when adding callbacks to it, are beyond me atm.
You’re totally right. I’d just started adding an addEventListener() method and was registering different callback varaibles, when I relised that I was suddenly suffering from scope creep! So I stopped. There’s only so many hours in the day you know!