Пример #1
0
        //--
        #endregion

        #region Private Attributes
        //-------------------------

        //--
        #endregion

        #region Public Properties
        //------------------------


        //--
        #endregion

        #region Public Methods
        //--------------------------


        //--
        #endregion

        public static void Main(String[] args)
        {
            try
            {
                int result = (int)EnumResultCode.S_OK;
                EndEvent = new AutoResetEvent(false);
                Console console = new Console();

                MyWin32.HandlerRoutine handlerRoutine = new MyWin32.HandlerRoutine(MyWin32.Handler);
                MyWin32.SetConsoleCtrlHandler(
                    handlerRoutine,
                    true);

                //create an instance of the generated DLL
                Dll usedDll = new Dll();

                // call the DLL's Start method; server will be initialized,
                // namespaces will be created and simulation thread will be started
                result = usedDll.Start();

                if (result != (uint)EnumResultCode.S_OK)
                {
                    return;
                }

                System.Console.WriteLine("The results will be written in the ClientDll.txt file");
                System.Console.WriteLine("Press \'e\' or \' q\' and 'ENTER' to exit");

                bool end = false;

                while (!Console.End && !end)
                {
                    String read = System.Console.ReadLine();
                    switch (read)
                    {
                    case "E":
                    case "e":
                    case "Q":
                    case "q":
                        end = true;
                        break;

                    default:
                        break;
                    }
                }                   //	end while


                //calls the DLL's Stop method which terminates the server application and closes the simulation thread
                usedDll.Stop();

                MyWin32.Handler(MyWin32.CtrlTypes.CTRL_CLOSE_EVENT);
            }
            catch (Exception exc)
            {
                System.Console.WriteLine(exc.ToString());
            } //	end try...catch
        }     //	end Main
Пример #2
0
        public static void Main(String[] args)
        {
            try
            {
                //create an instance of the generated DLL
                Dll usedDll = new Dll();

                // call the DLL's Start method; server will be initialized,
                // namespaces will be created and simulation thread will be started
                int result = usedDll.Start();

                if (result != (int)EnumResultCode.S_OK)
                {
                    return;
                }

                System.Console.WriteLine("Press \'e\' or \'q\' and then \'ENTER\'to exit");

                bool end = false;

                while (!end)
                {
                    String read = System.Console.ReadLine();
                    switch (read)
                    {
                    case "E":
                    case "e":
                    case "Q":
                    case "q":
                        end = true;
                        break;

                    default:
                        break;
                    }
                }                // while

                //calls the DLL's Stop method which terminates the server application and closes the simulation thread
                usedDll.Stop();
            }
            catch (Exception exc)
            {
                System.Console.WriteLine(exc.ToString());
            }
        } //	end Main