コード例 #1
0
        public override void Work()
        {
            var keyword = this.Context.KeywordQueue.Dequeue();

            Debug.WriteLine(String.Format("Selected Keyword({0}) {1}", this.Priority, keyword));
            SearchJob job = new SearchJob(this, keyword, 200);

            this.Context.JobQueue.Enqueue(job);
        }
コード例 #2
0
        public void AddSearchKeyword(string keyword)
        {
            //TODO 这里的参数应该可配置
            bool firstEnqueue = this.Context.KeywordQueue.Enqueue(keyword, 100);

            if (firstEnqueue)
            {
                SearchJob searching = this.Context.JobQueue.CurrentJob as SearchJob;
                if (searching != null && searching.Keyword == keyword)
                {
                    return;
                }
                KeywordSelectJob job = new KeywordSelectJob(this);
                this.Context.JobQueue.Enqueue(job);
                if (this.WorkingThread.ThreadState == ThreadState.WaitSleepJoin)
                {
                    this.WorkingThread.Interrupt();
                }
            }
        }