Delphi (native): Threaded BoxedApp

Questions, Support, etc.

Delphi (native): Threaded BoxedApp

Postby NilexBM on Wed Apr 08, 2009 11:35 am

We're using BoxedApp SDK with a Delphi native 32bit application. Since it takes about 6 seconds for BoxedApp to create the virtual Environment (4 virtual files, 1 ActiveX Control and 1 .Net Assembly),
I have chosen to do this in a separate thread created from the main program. This thread is running with a lower priority.

In the mean time (while the virtual environment is beeing established), the main program connects to a database and initializes the rest of the application.

The main program seems however to have problems to do DNS lookups while the BoxedApp environment is beeing established in the secondary thread.
The program is unable to connect to the database if, and only if, the address to the database is in a name format that requires a DNS lookup. (e.q. 'database_server.domain.se').
Using 'localhost' or a numeric IP as the database address works fine though.

Also, if we wait to connect until the secondary thread has terminated (i.e. the virtual environment is fully established), the program connects to the database just fine.

Does anybody have any clue what might cause this problem?
NilexBM
 
Posts: 10
Joined: Wed Apr 08, 2009 11:23 am

Re: Delphi (native): Threaded BoxedApp

Postby Artem A. Razin on Wed Apr 08, 2009 8:05 pm

Thank you for your question.

Is initialization thread working with virtual registry, may be it switches BoxedApp SDK to mode "all changes are virtual"?

Thank you.
Artem A. Razin
Site Admin
 
Posts: 746
Joined: Mon Jul 28, 2008 5:04 pm
Location: St.Petersburg, Russia

Re: Delphi (native): Threaded BoxedApp

Postby NilexBM on Tue Apr 14, 2009 1:59 pm

Thanks for you reply. I have however still not been able to solve this issue...

All my virtual files are beeing created using the function BoxedAppSDK_CreateVirtualFile, according to the example you have provided for Delphi, "FlashActiveXEmbedding".
I also tried to switch the BoxedAppSDK mode to "all changes are virtual" = false after the creation of each virtual file, but it didn't seem to have any impact at all.

Below you'll find the main structure of my program

Code: Select all
       Main Thread   

    [Start of program]
            |
      BoxedAppSDK_Init
            |
            |                                       Secondary thread
   [Create new thread] ------------------------------------+
            |                                              |
            |                                              |
       Database login                             Create Virtual Files
            |                                (BoxedAppSDK_CreateVirtualFile)
            |                                              |
     Program & Form setup                       Register ActiveX Control
            |                          (BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry)
            |                                              |
            |                               Register Dot.Net Assemblies for COM
            |      (repeated calls of BoxedAppSDK_CreateVirtualRegKey + RegOpenKey + RegSetValueEx + RegCloseKey)
            |                                              |
            |                                              |
            |                                    [Termination of thread]
            |                                              |
            |                                              |
[Wait for thread to terminate] ----------------------------+
            |
            |
           ///

[The virtual ActiveX Control and Assemblies will be used here]
 
           ///
            |
            |
   [Program to terminate]
            |
      BoxedAppSDK_Exit
            |
     [End of Program]       


The odd thing is that the database login procedure is unable to resolve the database address through a DNS lookup only while the secondary thread is running and If the program (i.e. Exe-file) is located on a network drive. Once the thread has terminated, the DNS lookup works without any problems.

Is it even possible to use BoxedApp in a threaded solution like this? The thread is created using the Delphi TThread class.
Any help would be appreciated.
NilexBM
 
Posts: 10
Joined: Wed Apr 08, 2009 11:23 am

Re: Delphi (native): Threaded BoxedApp

Postby Artem A. Razin on Tue Apr 14, 2009 7:11 pm

I have one idea related with BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry. I will write here soon.

Thank you.
Artem A. Razin
Site Admin
 
Posts: 746
Joined: Mon Jul 28, 2008 5:04 pm
Location: St.Petersburg, Russia

Re: Delphi (native): Threaded BoxedApp

Postby Artem A. Razin on Tue Apr 14, 2009 7:32 pm

Could you please try to comment call of the BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry ? Just to check, does it solve the problem.

Thank you.
Artem A. Razin
Site Admin
 
Posts: 746
Joined: Mon Jul 28, 2008 5:04 pm
Location: St.Petersburg, Russia

Re: Delphi (native): Threaded BoxedApp

Postby NilexBM on Wed Apr 15, 2009 7:36 am

Thanks for your great support!

I did some tests and replaced the call to BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry with a sleep(20000), i.e. the secondary thread pauses execution for about 20 seconds.
This seems to solve the problem, so the issue is most likely within that routine.

Another thing, to register an ActiveX Control using BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry seems to take about 4 seconds on my development machine. Is there any way to speed this up?

Thanks!
NilexBM
 
Posts: 10
Joined: Wed Apr 08, 2009 11:23 am

Re: Delphi (native): Threaded BoxedApp

Postby NilexBM on Wed Apr 15, 2009 8:00 am

I just made another test where I registered the ActiveX Control in the same manner as I do with the Dot.Net Assembly, i.e. I write all the necessary registry entries one at the time manually by code into the Virtual registry.

This seems also to work, so at least for the time beeing I've got a workaround for the problem. It would be nice if you could look into it though...

Thanks!
/Björn
NilexBM
 
Posts: 10
Joined: Wed Apr 08, 2009 11:23 am


Return to BoxedApp SDK

cron