Where is your code for InstallExecuteSequence/InstallUISequence?
<InstallUISequence>
<Custom Action="Testing" Sequence="1" />
</InstallUISequence>
Maybe adding this will make this custom action happen before your UI dialogs are called.
Edit: Also, have you done any detailed debugging (verbose logging) of your installer to check what is happening and when things are running? After you have your .MSI output, open a command prompt and do:
msiexec.exe /i <yourmsi> /l*vx Output.txt
This will give you detailed output of your stuff!