Invoke Event on boolean set in systemclass
I have my own TcpClient class that inherits TcpClient and I wanna invoke an event when one of the bools from TcpClient are set, is that possible?
Without checking it in a while loop that is?
8 Replies
if there are no events that are fired then unfortunately you have to poll
This would mean I'd still have to manually check in all the time?
"manually"
yep, unfortunately that's just how the language is. there are no mechanisms to hook up to changes of properties in the way you're describing
Dammit, I know you can make the setter of your own classes invoke an event so you don't have to check all the time so I got hope
I wanna do this because I have been using while loops to wait in code, abd that just hogs up stupid amount of resources...
yup, I mean you can use a
System.Threading.Timer
to invoke a check on another thread and then raise an event from that thread
prevents hogging up resources on the main thread, and that thing will only be invoked on another thread as often as you tell it to beI am already doing it on seperate thread but thanks, so unfortunate though :*
just how the language is, no intrinsic mechanism for modifying things like that
you can use something like harmony to patch the setter either entirely with your own code or just to invoke an event
but yeah that's an insane bit of over-engineering to solve that problem
over engineering is my name :D, i'll look into it eaither way thanks! I'll close the post now!