User-Supplied Main
Function Introduced:
In synchronous mode, the main() function of the Creo TOOLKIT program is not written by you, the application developer. In DLL mode, the main() is the root of the Creo Parametric program itself; in multiprocess synchronous mode, the main() is taken from the Creo TOOLKIT library, and its job is to set up the communication channel with the separate Creo Parametric executable.
If you are using a language such as C++ in your Creo TOOLKIT application, it can be advantageous to compile the main() function with the C++ compiler to ensure that the program structure is correct for C++. In DLL mode, you cannot do this because you do not have access to the Creo Parametric main(). But in multiprocess mode, you can substitute the Creo TOOLKIT main() with your own, if you observe the following rules:
• Your
main() must call the function
ProToolkitMain() as its last statement. This function contains all the necessary setup code that needs to be run when the
Creo TOOLKIT application starts up in multiprocess mode.
• You must pass on the
argc and
argv arguments input to
main() as the input arguments to
ProToolkitMain() without modifying them in any way.
• You cannot make calls to any other
Creo TOOLKIT functions before the call to
ProToolkitMain(), because the communications with
Creo Parametric have not yet been set up. You may, however, make other non-
Creo TOOLKIT function calls before calling
ProToolkitMain().
The following example shows a user-defined main() for use in multiprocess mode.
#include "ProToolkit.h"
main(
int argc,
char *argv[])
{
.
.
.
ProToolkitMain (argc, argv);
/* The program exits from within ProToolkitMain().
Any code here is not executed. */
}
Asynchronous Mode
For more information on the asynchronous mode, see section
Core: Asynchronous Mode.