TMS SmoothControl set to visible in child thread

I'm getting an access violation exception when trying to destroy a TMS component that was initially set Visible = false on the build and later set Visible = true in a child thread. I tried it with both a TAdvSmoothButton and a TAdvSmoothPanel in different apps and the same thing happened. When I call Synchronize() to execute this UI update, the problem no longer occurs. However, I'm confused, since the change to the Visible property and the closing of the application are not happening at the same time to have caused a race condition. Can anyone explain?

Hi, 


The component is created on the Main GUI Thread and changes in visibility should always be synchronized. As sample and explanation can be found at https://www.thoughtco.com/synchronizing-threads-and-gui-delphi-application-1058159

Pieter Scheldeman2017-06-16 08:49:10

Yes, but can you explain why a component created on the main GUI thread and only ever changed in the child thread would cause an access violation upon destruction without synchronization? The change to its visibility is completed long before its destruction. 

I guess what I'm asking is, can you explain exactly what the multi-thread conflict is in this scenario? In a race condition conflict two thread are trying to change the same thing at the same time. Since this is not what is happening in this case, what is?

When changing the visibility there are multiple things that happen, including calculations, which most likely keep memory allocated in a different thread, causing an issue when closing the thread, or application.