当前位置: 首页>>代码示例>>C#>>正文


C# Processor.ProcessSynchronously方法代码示例

本文整理汇总了C#中Processor.ProcessSynchronously方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.ProcessSynchronously方法的具体用法?C# Processor.ProcessSynchronously怎么用?C# Processor.ProcessSynchronously使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Processor的用法示例。


在下文中一共展示了Processor.ProcessSynchronously方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetLanguage

		/// <summary>
		/// 
		/// </summary>
		/// <param name="infos"></param>
		/// <returns></returns>
		public Return<object> SetLanguage(List<InfoGrp_Class> infos)
		{
			Return<object> _answer = new Return<object>();
			if (infos == null)
			{
				_answer.theresError = true;
				_answer.error = Utility.GetError(new ArgumentNullException("infos"), this.GetType());
			}
			else
			{
				try
				{
					List<InfoGrp_Class> _infosNoLanguage = infos.Where(i => !i.language.HasValue).ToList();
					if (_infosNoLanguage.Any())
					{
						int _numberSubprocess = _infosNoLanguage.Count < this.numberSubprocessLanguageIdentification ? _infosNoLanguage.Count : this.numberSubprocessLanguageIdentification;
						List<object> _objects = new List<object>();
						for (int _i = 0; _i < _numberSubprocess; _i++)
						{
							LanguageIdentificationUtility _object = new LanguageIdentificationUtility();
							Return<object> _answerLoadDefaultModels = _object.LoadDefaultModels();
							if (_answerLoadDefaultModels.theresError)
							{
								_answer.theresError = true;
								_answer.error = _answerLoadDefaultModels.error;
							}
							else
								_objects.Add(_object);

							if (_answer.theresError)
								break;
						}

						if (!_answer.theresError)
						{
							Stopwatch _stopwatch = new Stopwatch();
							string _tiempo = string.Empty;
							_stopwatch.Start();

							using (Processor<InfoGrp_Class> _processor = new Processor<InfoGrp_Class>(_numberSubprocess, MILLISECONDS_PAUSE_LANGUAGE_IDENTIFICATION, _objects))
							{
								_processor.ErrorProcessEntity += processorSetLanguage_ErrorProcessEntity;
								_processor.Progress += processorSetLanguage_Progress;

								_answer = _numberSubprocess == 1 ? _processor.ProcessSynchronously(_infosNoLanguage, SetLanguage)
																	: _processor.Process(_infosNoLanguage, SetLanguage);
								_processor.ErrorProcessEntity -= processorSetLanguage_ErrorProcessEntity;
								_processor.Progress -= processorSetLanguage_Progress;
							}

							_stopwatch.Stop();
							_tiempo = string.Format("{0} Ticks", _stopwatch.Elapsed.Ticks);
						}
					}
				}
				catch (Exception _ex)
				{
					_answer.theresError = true;
					_answer.error = Utility.GetError(_ex, this.GetType());
				}
			}
			return _answer;
		}
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:68,代码来源:GrpClassUtility.cs

示例2: CalculateProbabilitiesChangeStateNew

        private Return<List<LanguageIdentificationModelWrapper>> CalculateProbabilitiesChangeStateNew(int countSubprocesses, List<string> initialStrings, List<string> finalStrings
                                                                                                        , SafeSortedList<string, int> countCombinedStrings, SafeSortedList<string, int> countInitialStrings)
        {
            Return<List<LanguageIdentificationModelWrapper>> _answer = new Return<List<LanguageIdentificationModelWrapper>>() { data = new List<LanguageIdentificationModelWrapper>() };
            {
                try
                {
                    List<LanguageIdentificationModelWrapper> _allCombinations = (from _initialString in initialStrings
                                                                                 from _finalString in finalStrings
                                                                                 select new LanguageIdentificationModelWrapper(_initialString, _finalString, 1)
                                                                                                                                        )
                                                                                                                                        .ToList();
                    List<List<LanguageIdentificationModelWrapper>> _partitions = _allCombinations.PartitionAccordingSizeOfPartitions(SIZE_PARTITION_STRINGS);
                    List<ProbabilityChangeStateWrapper> _wrappers = _partitions.Select(p => new ProbabilityChangeStateWrapper()
                                                                                                            {
                                                                                                                countInitialStrings = countInitialStrings
                                                                                                                ,
                                                                                                                countCombinedStrings = countCombinedStrings
                                                                                                                ,
                                                                                                                fragmentsOfModel = p
                                                                                                            }
                                                                                                    ).ToList();

                    int _countSubprocesses = _wrappers.Count < countSubprocesses ? _wrappers.Count : countSubprocesses;

                    errorsMultithreadedProcess.Clear();
                    Return<object> _answerProcess = new Return<object>();
                    using (Processor<ProbabilityChangeStateWrapper> _processor
                                = new Processor<ProbabilityChangeStateWrapper>(_countSubprocesses, PAUSE_MILISECONDS_PROCESSOR))
                    {
                        _processor.ErrorProcessEntity += processorCalculateProbabilitiesChangeState_ErrorProcessEntity;
                        _processor.Progress += processorCalculateProbabilitiesChangeState_Progress;
                        _answerProcess = _countSubprocesses == 1 ? _processor.ProcessSynchronously(_wrappers, CalculateProbabilitiesChangeStateDirtyHands)
                                                                        : _processor.Process(_wrappers, CalculateProbabilitiesChangeStateDirtyHands);
                        _processor.Progress -= processorCalculateProbabilitiesChangeState_Progress;
                        _processor.ErrorProcessEntity -= processorCalculateProbabilitiesChangeState_ErrorProcessEntity;
                    }

                    if (_answerProcess.theresError)
                    {
                        _answer.theresError = true;
                        _answer.error = _answerProcess.error;
                    }
                    else
                        if (errorsMultithreadedProcess.Any())
                        {
                            _answer.theresError = true;
                            _answer.error = errorsMultithreadedProcess.First().Item2;
                        }
                        else
                            _answer.data = _wrappers.SelectMany(c => c.fragmentsOfModel).ToList();
                }
                catch (Exception _ex)
                {
                    _answer.theresError = true;
                    _answer.error = Utility.GetError(_ex, this.GetType());
                }
            }
            return _answer;
        }
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:60,代码来源:LanguageIdentificationUtility.cs

示例3: CalculateProbabilitiesInitialState

        private Return<List<LanguageIdentificationModelWrapper>> CalculateProbabilitiesInitialState(int countSubprocesses, List<string> sentences, List<string> initialStrings, List<WritableTuple<string, int>> countBeginningOfSentence)
        {
            Return<List<LanguageIdentificationModelWrapper>> _answer = new Return<List<LanguageIdentificationModelWrapper>>() { data = new List<LanguageIdentificationModelWrapper>() };
            {
                try
                {
                    int _countSentences = sentences.Count;
                    List<List<string>> _partitions = initialStrings.PartitionAccordingSizeOfPartitions(SIZE_PARTITION_STRINGS);
                    List<ProbabilityInitialStateWrapper> _wrappers = _partitions.Select(p => new ProbabilityInitialStateWrapper()
                                                                                                {
                                                                                                    countSentences = _countSentences
                                                                                                    ,
                                                                                                    countBeginningOfSentence = countBeginningOfSentence
                                                                                                    ,
                                                                                                    fragmentsOfModel = p.Select(pp => new LanguageIdentificationModelWrapper(pp, string.Empty, 1)).ToList()
                                                                                                }
                                                                                                    ).ToList();

                    int _countSubprocesses = _wrappers.Count < countSubprocesses ? _wrappers.Count : countSubprocesses;

                    errorsMultithreadedProcess.Clear();
                    Return<object> _answerProcess = new Return<object>();
                    using (Processor<ProbabilityInitialStateWrapper> _processor
                                = new Processor<ProbabilityInitialStateWrapper>(_countSubprocesses, PAUSE_MILISECONDS_PROCESSOR))
                    {
                        _processor.ErrorProcessEntity += processorCalculateProbabilitiesInitialState_ErrorProcessEntity;
                        _processor.Progress += processorCalculateProbabilitiesInitialState_Progress;
                        _answerProcess = _countSubprocesses == 1 ? _processor.ProcessSynchronously(_wrappers, CalculateProbabilitiesInitialStateDirtyHands)
                                                                        : _processor.Process(_wrappers, CalculateProbabilitiesInitialStateDirtyHands);
                        _processor.Progress -= processorCalculateProbabilitiesInitialState_Progress;
                        _processor.ErrorProcessEntity -= processorCalculateProbabilitiesInitialState_ErrorProcessEntity;
                    }
                    if (_answerProcess.theresError)
                    {
                        _answer.theresError = true;
                        _answer.error = _answerProcess.error;
                    }
                    else
                        if (errorsMultithreadedProcess.Any())
                        {
                            _answer.theresError = true;
                            _answer.error = errorsMultithreadedProcess.First().Item2;
                        }
                        else
                            _answer.data = _wrappers.SelectMany(c => c.fragmentsOfModel).ToList();
                }
                catch (Exception _ex)
                {
                    _answer.theresError = true;
                    _answer.error = Utility.GetError(_ex, this.GetType());
                }
            }
            return _answer;
        }
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:54,代码来源:LanguageIdentificationUtility.cs

示例4: CountBeginningOfSentence

        /// <summary>
        /// Performs a count of occurrences of a string into a beginning of a sentence
        /// </summary>
        /// <param name="countSubprocesses"></param>
        /// <param name="text">The sentences where to search into</param>
        /// <param name="strings">The strings to search</param>
        /// <returns>searched text, count of occurrences</returns>
        private Return<List<WritableTuple<string, int>>> CountBeginningOfSentence(int countSubprocesses, List<string> sentences, List<string> strings)
        {
            Return<List<WritableTuple<string, int>>> _answer = new Return<List<WritableTuple<string, int>>>() { data = new List<WritableTuple<string, int>>() };

            {
                try
                {
                    List<List<string>> _partitions = strings.PartitionAccordingSizeOfPartitions(SIZE_PARTITION_STRINGS);
                    List<CountWrapper> _wrappers = _partitions.Select(p => new CountWrapper()
                                                                                            {
                                                                                                sentences = sentences
                                                                                                ,
                                                                                                textToFind = p.Select(s => new WritableTuple<string, int>(s, 0)).ToList()
                                                                                            }
                                                                                ).ToList();

                    int _countSubprocesses = _wrappers.Count < countSubprocesses ? _wrappers.Count : countSubprocesses;

                    errorsMultithreadedProcess.Clear();
                    Return<object> _answerProcess = new Return<object>();
                    using (Processor<CountWrapper> _processor
                                = new Processor<CountWrapper>(_countSubprocesses, PAUSE_MILISECONDS_PROCESSOR))
                    {
                        _processor.ErrorProcessEntity += processorCountExistingStrings_ErrorProcessEntity;
                        _processor.Progress += processorCountExistingStrings_Progress;
                        _answerProcess = _countSubprocesses == 1 ? _processor.ProcessSynchronously(_wrappers, CountBeginningOfSentenceDirtyHands)
                                                                        : _processor.Process(_wrappers, CountBeginningOfSentenceDirtyHands);
                        _processor.Progress -= processorCountExistingStrings_Progress;
                        _processor.ErrorProcessEntity -= processorCountExistingStrings_ErrorProcessEntity;
                    }
                    if (_answerProcess.theresError)
                    {
                        _answer.theresError = true;
                        _answer.error = _answerProcess.error;
                    }
                    else
                        if (errorsMultithreadedProcess.Any())
                        {
                            _answer.theresError = true;
                            _answer.error = errorsMultithreadedProcess.First().Item2;
                        }
                        else
                        {
                            _answer.data = _wrappers.SelectMany(c => c.textToFind).ToList();
                        }
                }
                catch (Exception _ex)
                {
                    _answer.theresError = true;
                    _answer.error = Utility.GetError(_ex, this.GetType());
                }
            }
            return _answer;
        }
开发者ID:meras0704,项目名称:Solution_Blatella.ML,代码行数:61,代码来源:LanguageIdentificationUtility.cs


注:本文中的Processor.ProcessSynchronously方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。