Beispiel #1
0
        /// <summary>
        /// The application must call main after it has
        /// instantiated the derived class. main creates
        /// a communicator, establishes the specified signal policy, and,
        /// once run returns, destroys the communicator.
        /// The method prints an error message for any exception that propagates
        /// out of run and ensures that the communicator is
        /// destroyed correctly even if run completes abnormally.
        /// </summary>
        /// <param name="args">The arguments for the application (as passed to Main(string[])
        /// by the operating system.</param>
        /// <param name="initializationData">Additional data used to initialize the communicator.</param>
        /// <returns>The value returned by run. If run terminates with an exception,
        /// the return value is non-zero.</returns>
        public int main(string[] args, InitializationData initializationData)
        {
            if (Util.getProcessLogger() is ConsoleLoggerI)
            {
                Util.setProcessLogger(new ConsoleLoggerI(iceAppName));
            }

            if (iceCommunicator != null)
            {
                Util.getProcessLogger().error("only one instance of the Application class can be used");
                return(1);
            }

            //
            // We parse the properties here to extract Ice.ProgramName.
            //
            InitializationData initData;

            if (initializationData != null)
            {
                initData = (InitializationData)initializationData.Clone();
            }
            else
            {
                initData = new InitializationData();
            }

            try
            {
                initData.properties = Util.createProperties(ref args, initData.properties);
            }
            catch (Ice.Exception ex)
            {
                Util.getProcessLogger().error(ex.ToString());
                return(1);
            }
            catch (System.Exception ex)
            {
                Util.getProcessLogger().error("unknown exception:\n" + ex);
                return(1);
            }
            iceAppName = initData.properties.getPropertyWithDefault("Ice.ProgramName", iceAppName);

            iceNohup     = initData.properties.getPropertyAsInt("Ice.Nohup") > 0;
            _application = this;

            int status;

            if (iceSignalPolicy == SignalPolicy.HandleSignals)
            {
                _signals = new WindowsSignals();
                _signals.register(_handler);

                status = doMain(args, initData);

                _signals.destroy();
                _signals = null;
            }
            else
            {
                status = doMain(args, initData);
            }

            return(status);
        }
Beispiel #2
0
        /// <summary>
        /// The application must call main after it has
        /// instantiated the derived class. main creates
        /// a communicator, establishes the specified signal policy, and,
        /// once run returns, destroys the communicator.
        /// The method prints an error message for any exception that propagates
        /// out of run and ensures that the communicator is
        /// destroyed correctly even if run completes abnormally.
        /// </summary>
        /// <param name="args">The arguments for the application (as passed to Main(string[])
        /// by the operating system.</param>
        /// <param name="initializationData">Additional data used to initialize the communicator.</param>
        /// <returns>The value returned by run. If run terminates with an exception,
        /// the return value is non-zero.</returns>
        public int main(string[] args, InitializationData initializationData)
        {
            if(Util.getProcessLogger() is ConsoleLoggerI)
            {
                Util.setProcessLogger(new ConsoleLoggerI(appName__));
            }

            if(communicator__ != null)
            {
                Util.getProcessLogger().error("only one instance of the Application class can be used");
                return 1;
            }

            //
            // We parse the properties here to extract Ice.ProgramName.
            //
            InitializationData initData;
            if(initializationData != null)
            {
                initData = (InitializationData)initializationData.Clone();
            }
            else
            {
                initData = new InitializationData();
            }

            try
            {
                initData.properties = Util.createProperties(ref args, initData.properties);
            }
            catch(Ice.Exception ex)
            {
                Util.getProcessLogger().error(ex.ToString());
                return 1;
            }
            catch(System.Exception ex)
            {
                Util.getProcessLogger().error("unknown exception:\n" + ex);
                return 1;
            }
            appName__ = initData.properties.getPropertyWithDefault("Ice.ProgramName", appName__);

            nohup__ = initData.properties.getPropertyAsInt("Ice.Nohup") > 0;
            _application = this;

            int status;
#if COMPACT || UNITY
            status = doMain(args, initData);
#else
            if(signalPolicy__ == SignalPolicy.HandleSignals)
            {
                if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows)
                {
                    _signals = new WindowsSignals();
                }
                else
                {
                    _signals = new MonoSignals();
                }
                _signals.register(_handler);

                status = doMain(args, initData);

                _signals.destroy();
                _signals = null;
            }
            else
            {
                status = doMain(args, initData);
            }
#endif

            return status;
        }
Beispiel #3
0
        /// <summary>
        /// The application must call main after it has
        /// instantiated the derived class. main creates
        /// a communicator, establishes the specified signal policy, and,
        /// once run returns, destroys the communicator.
        /// The method prints an error message for any exception that propagates
        /// out of run and ensures that the communicator is
        /// destroyed correctly even if run completes abnormally.
        /// </summary>
        /// <param name="args">The arguments for the application (as passed to Main(string[])
        /// by the operating system.</param>
        /// <param name="initializationData">Additional data used to initialize the communicator.</param>
        /// <returns>The value returned by run. If run terminates with an exception,
        /// the return value is non-zero.</returns>
        public int main(string[] args, InitializationData initializationData)
        {
            if (Util.getProcessLogger() is ConsoleLoggerI)
            {
                Util.setProcessLogger(new ConsoleLoggerI(appName__));
            }

            if (communicator__ != null)
            {
                Util.getProcessLogger().error("only one instance of the Application class can be used");
                return(1);
            }

            //
            // We parse the properties here to extract Ice.ProgramName.
            //
            InitializationData initData;

            if (initializationData != null)
            {
                initData = (InitializationData)initializationData.Clone();
            }
            else
            {
                initData = new InitializationData();
            }

            try
            {
                initData.properties = Util.createProperties(ref args, initData.properties);
            }
            catch (Ice.Exception ex)
            {
                Util.getProcessLogger().error(ex.ToString());
                return(1);
            }
            catch (System.Exception ex)
            {
                Util.getProcessLogger().error("unknown exception:\n" + ex);
                return(1);
            }
            appName__ = initData.properties.getPropertyWithDefault("Ice.ProgramName", appName__);

            nohup__      = initData.properties.getPropertyAsInt("Ice.Nohup") > 0;
            _application = this;

            int status;

#if COMPACT || UNITY
            status = doMain(args, initData);
#else
            if (signalPolicy__ == SignalPolicy.HandleSignals)
            {
                if (IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows)
                {
                    _signals = new WindowsSignals();
                }
                else
                {
                    _signals = new MonoSignals();
                }
                _signals.register(_handler);

                status = doMain(args, initData);

                _signals.destroy();
                _signals = null;
            }
            else
            {
                status = doMain(args, initData);
            }
#endif

            return(status);
        }