コード例 #1
0
        public void HandleTyping(HintedControl control)
        {
            if (_searchThread1 != null || _searchThread2 != null || _searchThread3 != null)
            {
                _searchThread1.Abort();
                _searchThread2.Abort();
                _searchThread3.Abort();

                _searchThread1.Join();
                _searchThread2.Join();
                _searchThread3.Join();

                stageResult = null;
                movieResult = null;
                wordResult  = null;
            }

            FindBestSimilar(control.LastWord, control);
        }
コード例 #2
0
        public static void FindBestSimilar(string example, HintedControl control)
        {
            _searchThread1 = new Thread(
                () =>
            {
                stageResult = BestSimilarInArray(StageNames, example);
            });

            _searchThread1.Start();

            _searchThread2 = new Thread(
                () =>
            {
                movieResult = BestSimilarInArray(MovieTitles, example);
            });

            _searchThread2.Start();

            _searchThread3 = new Thread(
                () =>
            {
                wordResult = BestSimilarInArray(SimpleWords, example);

                _searchThread1.Join();
                _searchThread2.Join();

                if (wordResult.SimilarityScore > movieResult.SimilarityScore &&
                    wordResult.SimilarityScore > stageResult.SimilarityScore)
                {
                    Line = wordResult.Line;
                }
                else
                {
                    Line = (stageResult.IsBetterThan(movieResult) ? stageResult : movieResult).Line;
                }

                control.Hint = Line;
            });

            _searchThread3.Start();
        }