コード例 #1
0
        private void _Run(MethodInfo runMethod)
        {
            bool error = false;

            try
            {
                try
                {
                    _runChrono.Start();
                    runMethod.Invoke(null, null);
                    _runChrono.Stop();
                }
                catch (Exception ex)
                {
                    _runChrono.Stop();
                    error = true;
                    Trace.WriteError(ex);
                }
            }
            finally
            {
                _runThread = null;
                _endRun?.Invoke(error);
            }
        }
コード例 #2
0
        public static bool CompileProjects(string projectsFile, Win32ResourceCompiler win32ResourceCompiler, ResourceCompiler resourceCompiler = null, string runsourceSourceDirectory = null, Action<IProjectCompiler> onCompiled = null)
        {
            Chrono chrono = new Chrono();
            chrono.Start();
            int nbProject = 0;
            try
            {
                if (!zFile.Exists(projectsFile))
                    throw new PBException("projects file dont exists \"{0}\"", projectsFile);
                XmlConfig projects = new XmlConfig(projectsFile);
                string projectsDirectory = zPath.GetDirectoryName(projectsFile);
                //string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());

                string updateDirectory = projects.Get("UpdateDirectory");

                foreach (XElement project in projects.GetElements("Project"))
                {
                    string projectFile = project.zExplicitAttribValue("value").zRootPath(projectsDirectory);
                    Trace.WriteLine("Compile project \"{0}\"", projectFile);

                    ProjectCompiler compiler = ProjectCompiler.Create(projectFile, win32ResourceCompiler, resourceCompiler);
                    compiler.RunsourceSourceDirectory = runsourceSourceDirectory;
                    compiler.Compile();

                    //if (onCompiled != null)
                    //    onCompiled(compiler);
                    onCompiled?.Invoke(compiler);
                    if (!compiler.Success)
                        return false;
                    string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory());
                    if (copyOutput != null)
                    {
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", copyOutput);
                        compiler.CopyResultFilesToDirectory(copyOutput);
                    }
                    if (project.zAttribValue("copyToUpdateDirectory").zTryParseAs(false))
                    {
                        if (updateDirectory == null)
                            throw new PBException("update directory is not defined");
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", updateDirectory);
                        compiler.CopyResultFilesToDirectory(updateDirectory);
                    }
                    nbProject++;
                }
            }
            catch (ProjectCompilerException ex)
            {
                Error.WriteMessage(ErrorOptions.TraceError, ex.Message);
            }
            finally
            {
                chrono.Stop();
                Trace.WriteLine("{0} project(s) compiled", nbProject);
                Trace.WriteLine("Process completed {0}", chrono.TotalTimeString);
            }
            return true;
        }
コード例 #3
0
        private void CompileRunSource()
        {
            Chrono chrono = new Chrono();

            chrono.Start();
            int nbProject = 0;

            try
            {
                string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());
                Dictionary <string, List <string> > projectFiles = new Dictionary <string, List <string> >();

                foreach (XElement project in _config.GetElements("UpdateRunSource/Project"))
                {
                    ICompiler compiler = CompileProject(project.zExplicitAttribValue("value"));
                    if (compiler.HasError())
                    {
                        return;
                    }
                    string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory());
                    if (copyOutput != null)
                    {
                        //_trace.WriteLine("  copy result files to directory \"{0}\"", copyOutput);
                        compiler.CopyResultFilesToDirectory(copyOutput);
                    }
                    //_trace.WriteLine("  copy result files to directory \"{0}\"", updateDir);
                    compiler.CopyResultFilesToDirectory(updateDir);
                    nbProject++;
                }

                foreach (XElement project in _config.GetElements("UpdateRunSource/ProjectRunSourceLaunch"))
                {
                    ICompiler compiler = CompileProject(project.zExplicitAttribValue("value"));
                    if (compiler.HasError())
                    {
                        return;
                    }
                    string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory());
                    if (copyOutput != null)
                    {
                        //_trace.WriteLine("  copy result files to directory \"{0}\"", copyOutput);
                        compiler.CopyResultFilesToDirectory(copyOutput);
                    }
                    nbProject++;
                }
            }
            finally
            {
                chrono.Stop();
                _trace.WriteLine("{0} project(s) compiled", nbProject);
                _trace.WriteLine("Process completed {0}", chrono.TotalTimeString);
            }
        }
コード例 #4
0
 // Update is called once per frame
 void Update()
 {
     if (chrono.Stop())
     {
         GameOver();
     }
     if (trigger.LvlChecked())
     {
         nextLvl();
     }
     if (trigger.PuzzleCleared())
     {
         Win();
     }
 }
コード例 #5
0
        public static void Go()
        {
            Chrono.Start("Batch procedure");

            for (int i = 0; i < 10; i++)
            {
                Chrono.Start("Batch procedure;Cycle");
                Thread.Sleep(100);
                for (int j = 0; j < 10; j++)
                {
                    Chrono.Start("Batch procedure;Cycle;Inner Cycle");

                    Thread.Sleep(10);

                    Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 1");
                    Thread.Sleep(10);
                    Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 1");

                    Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 2");
                    Thread.Sleep(11);
                    Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 2");

                    Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 3");
                    Thread.Sleep(12);
                    Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 3");

                    Chrono.Stop("Batch procedure;Cycle;Inner Cycle");
                }
                Chrono.Stop("Batch procedure;Cycle");
            }

            for (int i = 0; i < 10; i++)
            {
                Chrono.Start("Batch procedure;Cycle2");
                Thread.Sleep(100);
                for (int j = 0; j < 10; j++)
                {
                    Chrono.Start("Batch procedure;Cycle2;Inner Cycle");
                    Thread.Sleep(10);
                    Chrono.Stop("Batch procedure;Cycle2;Inner Cycle");
                }
                Chrono.Stop("Batch procedure;Cycle2");
            }

            Chrono.Stop("Batch procedure");

            Chrono.ShowResults();
        }
コード例 #6
0
        public static bool CompileProjects(string projectsFile, Win32ResourceCompiler win32ResourceCompiler, ResourceCompiler resourceCompiler = null, string runsourceSourceDirectory = null, Action <IProjectCompiler> onCompiled = null)
        {
            Chrono chrono = new Chrono();

            chrono.Start();
            int nbProject = 0;

            try
            {
                if (!zFile.Exists(projectsFile))
                {
                    throw new PBException("projects file dont exists \"{0}\"", projectsFile);
                }
                XmlConfig projects          = new XmlConfig(projectsFile);
                string    projectsDirectory = zPath.GetDirectoryName(projectsFile);
                //string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());

                string updateDirectory = projects.Get("UpdateDirectory");

                foreach (XElement project in projects.GetElements("Project"))
                {
                    string projectFile = project.zExplicitAttribValue("value").zRootPath(projectsDirectory);
                    Trace.WriteLine("Compile project \"{0}\"", projectFile);

                    ProjectCompiler compiler = ProjectCompiler.Create(projectFile, win32ResourceCompiler, resourceCompiler);
                    compiler.RunsourceSourceDirectory = runsourceSourceDirectory;
                    compiler.Compile();
                    compiler.TraceMessages();

                    //if (onCompiled != null)
                    //    onCompiled(compiler);
                    onCompiled?.Invoke(compiler);
                    if (!compiler.Success)
                    {
                        return(false);
                    }
                    string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory());
                    if (copyOutput != null)
                    {
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", copyOutput);
                        compiler.CopyResultFilesToDirectory(copyOutput);
                    }
                    if (project.zAttribValue("copyToUpdateDirectory").zTryParseAs(false))
                    {
                        if (updateDirectory == null)
                        {
                            throw new PBException("update directory is not defined");
                        }
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", updateDirectory);
                        compiler.CopyResultFilesToDirectory(updateDirectory);
                    }
                    nbProject++;
                }
            }
            catch (ProjectCompilerException ex)
            {
                Error.WriteMessage(ErrorOptions.TraceError, ex.Message);
            }
            finally
            {
                chrono.Stop();
                Trace.WriteLine("{0} project(s) compiled", nbProject);
                Trace.WriteLine("Process completed {0}", chrono.TotalTimeString);
            }
            return(true);
        }
コード例 #7
0
ファイル: RunSourceRunCode_v1.cs プロジェクト: 24/source_04
        private void _Run(MethodInfo runMethod, MethodInfo initMethod = null, MethodInfo endMethod = null)
        {
            bool bError = false;

            try
            {
                _executionAborted = false;
                try
                {
                    if (initMethod != null)
                    {
                        _runCodeChrono.Start();
                        initMethod.Invoke(null, null);
                        _runCodeChrono.Stop();
                    }

                    _runCodeChrono.Start();
                    runMethod.Invoke(null, null);
                    _runCodeChrono.Stop();
                }
                catch (Exception ex)
                {
                    _runCodeChrono.Stop();
                    bError = true;
                    Trace.CurrentTrace.WriteError(ex);
                }
            }
            finally
            {
                try
                {
                    if (endMethod != null)
                    {
                        _runCodeChrono.Start();
                        endMethod.Invoke(null, null);
                        _runCodeChrono.Stop();
                    }
                }
                catch (Exception ex)
                {
                    _runCodeChrono.Stop();
                    bError = true;
                    Trace.CurrentTrace.WriteError(ex);
                }
                finally
                {
                    _runCodeThread    = null;
                    _executionPaused  = false;
                    _executionAborted = false;
                    if (EndRun != null)
                    {
                        EndRun(bError);
                    }
                    #region AppDomain ...
                    //******************************************************************************************************************************************************************************
                    //                                                                              AppDomain
                    //AppDomain.Unload(gDomain);
                    //gDomain = null;
                    //******************************************************************************************************************************************************************************
                    #endregion
                }
            }
        }
コード例 #8
0
 /// <summary>
 /// Mise en pause du chronomètre
 /// </summary>
 /// <param name="chrono">le chronomètre dont l"état doit changer</param>
 public async Task PauseChrono(Chrono chrono)
 {
     chrono.Stop();
     GetColorEtatChrono(chrono);
     await ListTimer.SaveFile();
 }