Concept : Understanding the Main Class and Run Functions
Contents |
[edit] Description
To ensure that your applications's start-up code runs as intended, Bungee Connect provide you with the ability to add or assign a Main class and Run function to your application's primary AppProject.
Then, when your application starts, an instance of the Main class is created, and the Run function is executed. The run function provides a location to place your application's start-up code and to initialize items when your application runs.
[edit] Optimizing Your Application Start Time
Caveat The following functionality will be available in the code release scheduled for the end of February 2008.
If you have an application that loads slower than you want, you can optimize apparent application load times by splitting the application load and initialization functionality between two functions on your application's main class.
When a request comes in to start up an application, if you have added or assigned a class to act as the application's "Main" class, that class is checked to see if there is a function which uses the MainRunFunction function adapter. This function is called before any response is sent to the browser. This means that any functionality you place in this function has a direct impact on how long it takes for a user to see something appear in the application area of the browser. Keep this function as small and tight as possible so your application launches quickly. The main purpose for providing a function to which you have assigned the mainrunfunction function adapter, is to control what your users see first.
Once that function returns, the browser renders the first page. If you have provided your main class with a function to which you have assigned the MainPostRenderInitFunction adapter, this function is called immediately after the initial page renders and before the user can do anything to interact with your application. Use this function to do most of your application initialization. For example, if your application requires user authentication, this function is a good place to call your login dialog.
See the image below for a graphical explanation of what happens when you launch an application under the conditions described above.
[edit] See Also
Providing a Main Class And Run Functions
Solutions and Projects
Creating a Solution
Adding a Project to a Solution