コード例 #1
0
        private void ToolStripButtonGoClick(object sender, EventArgs e)
        {
            IsRunning = true;

            string       path         = FolderTree.SelectedPath;
            Language     language     = ByLanguageFactory.GetLanguageFromString(toolStripComboBoxLanguage.Text);
            FileIterator fileIterator = ByLanguageFactory.GetFileIterator(language);

            IBlacklist   blacklist = ByLanguageFactory.GetBlacklist(language);
            IWordStemmer stemmer   = ByLanguageFactory.GetStemmer(language);

            SetCaptionText("Estimating ...");

            string[] files = fileIterator
                             .GetFiles(path)
                             .ToArray();

            ToolStripProgressBar.Maximum = files.Length;

            m_CloudControl.WeightedWords = new List <IWord>();

            //Note do not dispose m_CancelSource it will be disposed by task
            //TODO need to find correct way to work with CancelationToken
            //http://stackoverflow.com/questions/6960520/when-to-dispose-cancellationtokensource
            m_CancelSource = new CancellationTokenSource();
            Task.Factory
            .StartNew(
                () => GetWordsParallely(files, language, blacklist, stemmer), m_CancelSource.Token)
            .ContinueWith(
                ApplyResults);
        }
コード例 #2
0
        private void ScanDirectory(string scandir)
        {
            try
            {
                using (new CursorKeeper(Cursors.WaitCursor))
                {
                    IEnumerable <string> browseEnum = FileIterator.GetFiles(scandir, "*.mp3");
                    string[]             files      = browseEnum.ToArray();

                    _form.SetDirectoryList(files);

                    // success; save the directory
                    _rootdir = scandir;
                    Properties.Settings.Default.Directory = _rootdir;
                    Properties.Settings.Default.Save();
                }
            }
            catch (Exception ex)
            {
                Utils.ExceptionMessageBox.Show(ex, "Directory Scan failed.");
            }
        }