Well what I do usually prevent the BE from needing a compact by having any temp tables and such in a seperate BE that gets replaced with empty database where/when needed.
Depending on database size & network speed your compact can take a while.... Theoriticaly you should be able to check for the existance of yourDatabaseBE.LDB.
If that exists then it is is use, if not there, not in use... Keep in mind that during compact NO ONE can use the BE-DB