コード例 #1
0
ファイル: IKMeansProvider.cs プロジェクト: sdluxeon/Polaris
        public Deviation GetDeviation(double[] numbers, int deviationPercent)
        {
            var       avg             = new AvarageDeviationMeans();
            var       ballancedKMeans = new AvarageDeviationMeans();
            Deviation dev             = null;
            var       task            = Task.Run(() => dev = ballancedKMeans.GetDeviation(numbers, deviationPercent));

            if (Task.WhenAny(task, Task.Delay(3000)).Result == task)
            {
                return(dev);
            }
            else
            {
                return(avg.GetDeviation(numbers, deviationPercent));
            }
        }