Click here to Skip to main content
15,904,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to to change a textbox text when a read-only property changes... I don't have access to the property source because it is from an external library. I just want to check whenever the code changes a Boolean property for example, like events, do something when this event happens. if the READ-ONLY PROPERTY is true then button1.content = "T" else = "F".... is that even possible in or c#?

UPDATE : Here is what I'm trying to achieve, first im using SlimDX library to detect Gamepad Buttons, to detect buttons using this lib u should use Joystick.State.IsPressed(*Button Number as int*) to check manually for it if it is pressed it will return True.. to check it I need to use Timer, but this way with a big code in it, timer seems a bad way and cpu killer, So I need to check whenever this boolean (Joystick.State.IsPressed (0)) had changed to do my code.. An event for that if possible. .. Thanks Guys
Updated 3-Aug-14 16:07pm

1 solution

Is it enough to provide the user a Refresh button?
Or update it after the user performs another action in your application?

Otherwise, you'll likely need a background worker thread to perform the action -- not difficult, and a Timer will probably work well for you.
Share this answer
Sergey Alexandrovich Kryukov 3-Aug-14 21:07pm    
Frankly, a timer or thread checking for property change is a very, very bad idea. First of all, it does not solve the problem. With some probability, the property can be changed and than changed again to the same value, and it can happen between the check, which leaves the change undetected. I hope you are not the one who agree to solve the problem with certain probability...

Now, the problem is very simple: it's a problem of 3rd-party library. The detection of property change can be possible through some event or not. If not, it is 1) maybe just not needed, 2) the library is not fully functional, not suitable to the user.

PIEBALDconsult 3-Aug-14 21:48pm    
"leaves the change undetected"

Sure, but I don't think that matters to the OP in this case. I read it as he wants to know the current state, regardless of how many changes are made.
If he wants to know every change, then I see no way to accomplish that without support from the class.
Boudi AlSayed 3-Aug-14 21:53pm    
yeah you might be right.. I'm trying to find the source of the class as it is an open source library... but no luck till now
Boudi AlSayed 3-Aug-14 21:47pm    
im doing a Gamepad to keyboard app, everything worked till now. I'm using SlimDx library to get input of my Gamepad buttons, Unfortunately, there is no Keypress event in this library, so I have to figure out a way to check whenever a key is pressed down and up.. to know that, there is a Joystick.State.IsPressed(*Button number as int*), and you have to check it manually, or use a timer which is not a good idea and will be taking alot of cpu power to process all code in timer... So I need to check if the State.IsPressed(0) had changed to True or not... by making an event for that if it is possible. .
PIEBALDconsult 3-Aug-14 21:51pm    
Ah, then yes, a Timer may not be enough, but I can't see a way to get what you want.
Please update/improve your question by adding this detail to it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900