Exemple #1
0
        private FileHelperAsyncEngine <T> SplitAndSortParts(string file, List <string> res)
        {
            int partNumber = 1;

            var lines = new List <T>();

            try {
                long writtenBytes     = 0;
                long lastWrittenBytes = 0;
                var  readEngine       = new FileHelperAsyncEngine <T>(Encoding);

                readEngine.Progress += (sender, e) => writtenBytes = e.CurrentBytes;

                using (readEngine.BeginReadFile(file, EngineBase.DefaultReadBufferSize * 2)) {
                    foreach (var item in readEngine)
                    {
                        lines.Add(item);

                        if ((writtenBytes - lastWrittenBytes) > BlockFileSizeInBytes)
                        {
                            WritePart(file, lines, partNumber, res);
                            partNumber++;
                            lastWrittenBytes = writtenBytes;
                        }
                    }
                }

                return(readEngine);
            }
            finally {
                if (lines.Count > 0)
                {
                    WritePart(file, lines, partNumber, res);
                }
            }
        }
 public AsyncEnumerator(FileHelperAsyncEngine <T> engine)
 {
     mEngine = engine;
 }
            public AsyncEnumerator(FileHelperAsyncEngine <X> engine)
#endif
            {
                mEngine = engine;
            }
 public AsyncEnumerator(FileHelperAsyncEngine engine)
Exemple #5
0
        /// <summary>
        /// Read with asnc engine, creating the engine
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T[] ReadWithAsyncEngine <T>() where T : class
        {
            var engine = new FileHelperAsyncEngine <T>();

            return(ReadWithAsyncEngine(engine));
        }