Property Changed event transfers the control to a different thread

Hello
I have a thread/function A blocked, waiting for StringValue:Changed:Wait() event to fire.
Then in another thread/function B the given Value is changed. However the control is immediately transferred to the waiting function A before function B finishes.
This is unexpected to me and a possible cause of problems because lines of code which are supposed to be executed together in function B are now interrupted by other code in a different thread.
(I am not even sure when the control will be returned again to thread B, will it be placed at the end of the task scheduler queue…)

How do you handle this and what is the correct approach?

Thanks

1 Like

Hi, what is preventing you from changing the Value at the end of function B?

1 Like