Thread freeze using hints in a DLL...

B a c k g r o u n d
I have developed an ActiveX that use hints. This ActiveX did freeze Internet
Explorer and the end users had to kill this app with the task manager or
restart the computer.

T e s t s
Several tests were made and finally we found out that this behaviour was
caused by the hints in Delphi. When running as a DLL a hint thread manages
the hints. The hints could then be removed by a hint message or by the
thread itself.

What I found (I think) is a conflict when both the thread and the window
message will try to remove the hint. This will cause the freeze.

To force this error I created a very small DLL and an EXE file that called
it. The main theory behind freezing the application is to perform many heavy
things (in the DLL) that will queue up many window messages (including hint
messages) at the same time as a hint is visible on the screen. The Window
queue will not be handled before the heavy things are ready.

At the same time you should move the mouse (when the DLL-hint is visible)
outside the application to a non-Delphi form. Briefly: when the queue will
try to remove the hint (by the message handler) it is already gone and the
application will freeze upon a call to WitForSingleObject with "Infinite" as
a parameter.

Q u e s t i o n
I found a solution to this problem that I believe is a good solution, but I
want to know if anyone can see any dangerous situations by doing so?

S o l u t  i o n
In FORMS.PAS the hint thread is managed in a procedure called
"HintMouseThread". This procedure will sometimes call
Application.CancelHint. By just skipping this Application.CancelHint the
problem disappear! I think this is the same as not using the thread at all
and this also leave the task to the window hint messages. There must be a
reason for using these hint threads. I think that the messages (under some
circumstances) will not be removed. This is though better than freezing the

Sorry for not being short, but it is hard to explain this complicated matter
in any other way,

Kind Regards,

/Peter J?derlund