Ejemplo n.º 1
0
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Starting");
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            var ct = new CancellationToken();
            var cts = new CancellationTokenSource();
            var ascb = new AscDataBlocks
            {
                Start = 1,
                End = 151
            };
            try
            {
                var ascbuffer = new BufferBlock<Parse>(new ExecutionDataflowBlockOptions
                {
                    MaxDegreeOfParallelism = 5,
                    CancellationToken = ct
                });
                var ascProcessingconsumer = ascb.AscTransConsumerAsync(ascbuffer);
                //Post source data to the dataflow block.
                ascb.AscBufferProducer(ascbuffer);
                ascbuffer.Complete();

                ascProcessingconsumer.Wait(cts.Token);
                stopwatch.Stop();

                // Write hours, minutes and seconds.

                Logger.Debug("Time elapsed: {0:hh\\:mm\\:ss}", stopwatch.Elapsed);
                Console.WriteLine("Done");

            }
            catch (Exception ex)
            {

                Logger.Error(ex);
            }

        }
Ejemplo n.º 2
0
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Starting");
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var ct   = new CancellationToken();
            var cts  = new CancellationTokenSource();
            var ascb = new AscDataBlocks
            {
                Start = 1,
                End   = 151
            };

            try
            {
                var ascbuffer = new BufferBlock <Parse>(new ExecutionDataflowBlockOptions
                {
                    MaxDegreeOfParallelism = 5,
                    CancellationToken      = ct
                });
                var ascProcessingconsumer = ascb.AscTransConsumerAsync(ascbuffer);
                //Post source data to the dataflow block.
                ascb.AscBufferProducer(ascbuffer);
                ascbuffer.Complete();

                ascProcessingconsumer.Wait(cts.Token);
                stopwatch.Stop();

                // Write hours, minutes and seconds.

                Logger.Debug("Time elapsed: {0:hh\\:mm\\:ss}", stopwatch.Elapsed);
                Console.WriteLine("Done");
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }