Exemplo n.º 1
0
        public async Task Start()
        {
            // Options of the many-threads blocks
            // Limit a max bounded capacity to improve a consumption of memory
            var parallelBlockOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount, BoundedCapacity = 1000
            };

            // Blocks of the processing data
            var eventBlock = new ActionBlock <string>((text) => callback(text), parallelBlockOptions);

            // Reading tech log block
            var readBlock = new ActionBlock <string>((filePath) => TechLogHelper.ReadLogFile(filePath, eventBlock), parallelBlockOptions);

            foreach (var file in logFiles)
            {
                await readBlock.SendAsync(file);
            }

            // Mark block as completed
            readBlock.Complete();

            await readBlock.Completion.ContinueWith(c => eventBlock.Complete());

            await eventBlock.Completion;
        }
Exemplo n.º 2
0
 public TechLogEventReader(LogCfg logcfg, Action <string> callback)
 {
     logFiles      = TechLogHelper.GetLogFiles(logcfg);
     this.callback = callback;
 }
Exemplo n.º 3
0
 public TechLogEventReader(string logParentFolder, Action <string> callback)
 {
     logFiles      = TechLogHelper.GetLogFiles(logParentFolder);
     this.callback = callback;
 }