Exemplo n.º 1
0
        /// <summary>
        /// File list has been built, now its time to crack open each file
        /// and count the code
        /// </summary>
        private void ProcessFileList()
        {
            // now we are ready to count the files
            CodeCounterEngine codeCounterEngine = new CodeCounterEngine();

            _eventReset = new AutoResetEvent(false);
            object lockObject = new object();

            // hook up finished even handler (required)
            codeCounterEngine.OnFinish += new CodeCounterFinishedEvent(OnCodeCountingFinished);

            if (0 < _listOfFiles.Count)
            {
                Console.WriteLine(string.Format("counting {0} possible files", _listOfFiles.Count));
            }

            // only add these event handlers if the user wanted output
            if (false == _quiet)
            {
                codeCounterEngine.OnStart  += new CodeCounterUpdateEvent(OnCodeCountingStart);
                codeCounterEngine.OnUpdate += new CodeCounterUpdateEvent(OnCodeCountingUpdate);
            }

            // for each file in the array
            foreach (IScanForFilesData file in _listOfFiles)
            {
                try
                {
                    codeCounterEngine.File = file.FileInfo;

                    // clean everything up
                    while (true == Console.KeyAvailable)
                    {
                        Console.Read();
                    }

                    _spinnerPosition   = 0;
                    _erasableTextLengh = 0;
                    _eventReset.Reset();

                    // make erasure execute on a separate thread
                    ThreadStart codeCountThreadStart = new ThreadStart(codeCounterEngine.Count);
                    Thread      codeCountThread      = new Thread(codeCountThreadStart);
                    codeCountThread.Name = "codeCountingThread worker";
                    codeCountThread.Start();

                    _eventReset.WaitOne();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// File list has been built, now its time to crack open each file
        /// and count the code
        /// </summary>
        private void ProcessFileList()
        {
            // now we are ready to count the files
            CodeCounterEngine codeCounterEngine = new CodeCounterEngine();
            _eventReset = new AutoResetEvent(false);
            object lockObject = new object();

            // hook up finished even handler (required)
            codeCounterEngine.OnFinish += new CodeCounterFinishedEvent(OnCodeCountingFinished);

            if (0 < _listOfFiles.Count)
                Console.WriteLine(string.Format("counting {0} possible files", _listOfFiles.Count));

            // only add these event handlers if the user wanted output
            if (false == _quiet)
            {
                codeCounterEngine.OnStart += new CodeCounterUpdateEvent(OnCodeCountingStart);
                codeCounterEngine.OnUpdate += new CodeCounterUpdateEvent(OnCodeCountingUpdate);
            }

            // for each file in the array
            foreach (IScanForFilesData file in _listOfFiles)
            {
                try
                {
                    codeCounterEngine.File = file.FileInfo;

                    // clean everything up
                    while (true == Console.KeyAvailable)
                        Console.Read();

                    _spinnerPosition = 0;
                    _erasableTextLengh = 0;
                    _eventReset.Reset();

                    // make erasure execute on a separate thread
                    ThreadStart codeCountThreadStart = new ThreadStart(codeCounterEngine.Count);
                    Thread codeCountThread = new Thread(codeCountThreadStart);
                    codeCountThread.Name = "codeCountingThread worker";
                    codeCountThread.Start();

                    _eventReset.WaitOne();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    Console.WriteLine(ex.Message);
                }
            }
        }