コード例 #1
0
        private static void MainAnalysisThreadedTask(RawFileName rawfile, SettingsForAnalysis fixedSettingsForAnalysis, UIsettings fixedSettings, ResultItems results)
        {
            //ResultItems results = new ResultItems();

            //this can now be done threaded

            List <Task <ResultItems> > taskList = new List <Task <ResultItems> >();

            taskList.Add(Task.Run(() =>
            {
                ResultItems results1 = new ResultItems();
                using (AnalysisTemplate curMethod = new AnalysisMorpheus())
                {
                    results1 = curMethod.Analyze(rawfile, fixedSettingsForAnalysis, fixedSettings);
                }
                GC.Collect();//ugly but this solves problem with memory not released
                return(results1);
            }));
            taskList.Add(Task.Run(() =>
            {
                ResultItems results2 = new ResultItems();
                using (AnalysisTemplate curMethod = new AnalysisBase())
                {
                    results2 = curMethod.Analyze(rawfile, fixedSettingsForAnalysis, fixedSettings);
                }
                return(results2);
            }));
            taskList.Add(Task.Run(() =>
            {
                ResultItems results3 = new ResultItems();
                using (AnalysisTemplate curMethod = new AnalysisExternal1())
                {
                    results3 = curMethod.Analyze(rawfile, fixedSettingsForAnalysis, fixedSettings);
                }
                return(results3);
            }));

            Task.WaitAll(taskList.ToArray());
            foreach (Task <ResultItems> resultTask in taskList)
            {
                results.Add(resultTask.Result);
            }

            //return results;
        }
コード例 #2
0
        /*
         * private void GetPossibleUpdateOfSettings(ref List<SettingsForAnalysis> list, ref UIsettings uisettings)
         * {
         *  var timeout = TimeSpan.FromMilliseconds(500);
         *  bool lockTaken = false;
         *  bool success = false;
         *  int i = 5; //no of times to try
         *  while (success & i > 0)
         *  {
         *      try
         *      {
         *          Monitor.TryEnter(settingLock, timeout, ref lockTaken);
         *          if (lockTaken)
         *          {
         *              if (updateNeeded & newSettings.Count > 0)
         *              {
         *                  list = this.newSettings;
         *                  this.newSettings = new List<SettingsForAnalysis>();
         *                  uisettings = this.newUIsettings;
         *                  this.newUIsettings = new UIsettings();
         *              }
         *              success = true;
         *              updateNeeded = false;
         *          }
         *      }
         *      catch
         *      {
         *          success = false;
         *      }
         *      finally
         *      {
         *          // Ensure that the lock is released.
         *          if (lockTaken)
         *          {
         *              Monitor.Exit(settingLock);
         *          }
         *      }
         *  }
         *  if (success)
         *  {
         *      Log.Information("Updated analysis settings");
         *  }
         *  else
         *  {
         *      Log.Warning("Failed update of analysis settings (this shouldn't happen) - try to stop the monitoring and start it again");
         *  }
         * }
         */
        private List <Tuple <string, Type> > GetDataTable(UIsettings settingName)
        {
            List <Tuple <string, Type> > colNames = new List <Tuple <string, Type> >();

            using (AnalysisTemplate curMethod = new AnalysisMorpheus())
            {
                colNames.AddRange(curMethod.GetResultList(settingName));
            }
            using (AnalysisTemplate curMethod = new AnalysisBase())
            {
                colNames.AddRange(curMethod.GetResultList(settingName));
            }
            using (AnalysisTemplate curMethod = new AnalysisExternal1())
            {
                colNames.AddRange(curMethod.GetResultList(settingName));
            }
            return(colNames);
        }