예제 #1
0
        public void Check_thread()
        {
            _directory_list = new List<string>();
            _triggered_count = 0;
            _triggered = false;
            _path = "c:/";

            DirectoryWalker dw = new DirectoryWalker();
            Assert.NotNull(dw);

            // add Subscriber
            dw.OnDiscoverDir += new DirectoryWalker.HandleEventView(this.DirWalkEventHandler);

            // set running condition
            dw.SetMaxLevel(2);
            dw.SetTargetPath("c:/users");

            Thread worker = new Thread(new ThreadStart(dw.AsyncGetDirTree));
            worker.Start();
            Thread.Sleep(100);

            Console.WriteLine("join thread");

            worker.Abort();
            //worker.Join();
        }
예제 #2
0
        public void Content_Check()
        {
            _directory_list = new List<string>();
            _triggered_count = 0;
            _triggered = false;
            string test_path = "c:/users";

            DirectoryWalker dw = new DirectoryWalker();
            Assert.NotNull(dw);

            // add Subscriber
            dw.OnDiscoverDir += new DirectoryWalker.HandleEventView(this.DirWalkEventHandler);
            // set running condition
            dw.SetMaxLevel(2);
            dw.SetTargetPath(test_path);
            dw.SetDelay(0);

            string[] directory_sample = Directory.GetDirectories(test_path);

            Thread worker = new Thread(new ThreadStart(dw.AsyncGetDirTree));
            worker.Start();
            Thread.Sleep(100);

            foreach (string dir in _directory_list)
            {
                Console.WriteLine("<<" + dir);
            }

            foreach (string dir in directory_sample)
            {
                Console.WriteLine(">>" + dir);
                Assert.True(_directory_list.Contains(dir));
            }

            // directory_sample has 1 less directory because it doesnt contain the base dir.
            Assert.AreEqual(directory_sample.Length, _directory_list.Count - 1);
        }
예제 #3
0
        private void Start_Directory_Walk()
        {
            Console.WriteLine("Im starting a dir walk request");

            if (_dirWalker != null)
            {
                if (_dirWalker.IsInProgress())
                {
                    //Console.WriteLine("operation in progress");
                    //TODO display MsgBox operation in progress
                    MessageBox.Show("Request in progress");
                    return;
                }
                else
                {
                    // the last request is finished. So reclaim this thread.
                    //_dataModel.Join();
                }
            }

            _dirWalker = new DirectoryWalker();

            // Setup subscribers - this could be wrapped into a _dirWalker.Subscribe method.
            _dirWalker.OnDiscoverDir += new DirectoryWalker.HandleEventView(UpdateDirEvent);
            _dirWalker.OnDiscoverDir += new DirectoryWalker.HandleEventView(UpdateProgressBar);

            // prep the obj

            if (!IsBaseDirValid())
            {
                MessageBox.Show("No such directory " + entryBaseDir.Text);
                return;
            }

            // we know entryBaseDir.Text is valid.
            _dirWalker.SetTargetPath(entryBaseDir.Text);
            _dirWalker.SetMaxLevel(10);

            progressBar1.Style = ProgressBarStyle.Marquee;

            // start the data model in a thread.
            _dataModel = new Thread(new ThreadStart(_dirWalker.AsyncGetDirTree));
            _dataModel.Start();
        }
예제 #4
0
        public void Test_Walk()
        {
            string test_path = "c:\\users";

            DirectoryWalker dw = new DirectoryWalker();
            dw.OnDiscoverDir += new DirectoryWalker.HandleEventView(this.DirWalkEventHandler);
            Thread worker = new Thread(new ThreadStart(dw.AsyncGetDirTree));
            dw.SetMaxLevel(2);
            dw.SetTargetPath(test_path);

            worker.Start();

            //Thread.Sleep(5000);
            //Console.WriteLine ( dw.DirTree_r1("c:\\users", 5) );
        }