public void CleanUp()
 {
     _provider.Dispose();
     _provider = null;
     GC.Collect(int.MaxValue, GCCollectionMode.Forced, true);
     GC.WaitForPendingFinalizers();
 }
Пример #2
0
        /// <summary>
        /// Using multiple threads loops through the useragents in the file
        /// provided perform a match with the data set provided passing
        /// control back to the method provided for further processing.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="userAgents"></param>
        /// <param name="method"></param>
        /// <returns>Counts for each of the methods used</returns>
        internal static Results DetectLoopMultiThreaded(TrieProvider provider, IEnumerable <string> userAgents, ProcessTrie method, object state)
        {
            var results = new Results();

            Parallel.ForEach(userAgents, line =>
            {
                method(results, provider.GetDeviceIndex(line.Trim()), state);
                Interlocked.Increment(ref results.Count);
            });
            ReportMethods(results.Methods);
            ReportTime(results);
            return(results);
        }
Пример #3
0
        /// <summary>
        /// In a single thread loops through the useragents in the file
        /// provided perform a match with the data set provided passing
        /// control back to the method provided for further processing.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="userAgents"></param>
        /// <param name="method"></param>
        /// <returns>Counts for each of the methods used</returns>
        internal static Results DetectLoopSingleThreaded(TrieProvider provider, IEnumerable <string> userAgents, ProcessTrie method, object state)
        {
            var results = new Results();

            foreach (var line in userAgents)
            {
                method(results, provider.GetDeviceIndex(line.Trim()), state);
                results.Count++;
            }
            ReportMethods(results.Methods);
            ReportTime(results);
            return(results);
        }
 internal Validation(TrieProvider provider)
 {
     Provider = provider;
 }
Пример #5
0
 public void CreateDataSet()
 {
     Utils.CheckFileExists(DataFile);
     _provider = TrieFactory.Create(DataFile, false);
 }