C
C#2y ago
Blix

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
Doombox
Doombox2y ago
if there are no events that are fired then unfortunately you have to poll
Blix
BlixOP2y ago
This would mean I'd still have to manually check in all the time? "manually"
Doombox
Doombox2y ago
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
Blix
BlixOP2y ago
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...
Doombox
Doombox2y ago
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 be
Blix
BlixOP2y ago
I am already doing it on seperate thread but thanks, so unfortunate though :*
Doombox
Doombox2y ago
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
Blix
BlixOP2y ago
over engineering is my name :D, i'll look into it eaither way thanks! I'll close the post now!
Want results from more Discord servers?
Add your server