예제 #1
0
        public static async Task <ProcessedInvoice[]> ProcessInvoices(params string[] files)
        {
            //textBlock.Text = results[0].Email;
            ProcessedInvoice[] results   = null;
            Stopwatch          stopwatch = Stopwatch.StartNew();

            stopwatch.Start();


            await Task.Run(() =>
            {
                results = InvoiceProcessor.Process(files);
                Application.Current.Dispatcher.Invoke(() =>
                {
                    stopwatch.Stop();
                    foreach (ProcessedInvoice inv in results)
                    {
                        // textBlock.Text += $"{inv.ABN} : {inv.Email} | GST: {inv.GstRegistered} \n";
                        TryABN(inv);
                    }
                    //textBlock.Text += "\n Time: " + stopwatch.Elapsed;
                });

                return(results);
            });

            return(results);
        }
예제 #2
0
        void ProcessInvoices(string[] files)
        {
            //textBlock.Text = results[0].Email;
            ProcessedInvoice[] results   = null;
            Stopwatch          stopwatch = Stopwatch.StartNew();

            stopwatch.Start();
            processingBar.IsIndeterminate = true;
            processingBar.Visibility      = Visibility.Visible;
            int processedCount = 0;
            var t = Task.Run(() =>
            {
                results = InvoiceProcessor.Process(files);
                this.Dispatcher.Invoke(() =>
                {
                    processingBar.IsIndeterminate = false;
                    stopwatch.Stop();
                    foreach (ProcessedInvoice inv in results)
                    {
                        processedCount++;
                        // textBlock.Text += $"{inv.ABN} : {inv.Email} | GST: {inv.GstRegistered} \n";
                        TryABN(inv);
                        processingBar.Value = processingBar.Maximum * (results.Length / processedCount);
                    }
                    //textBlock.Text += "\n Time: " + stopwatch.Elapsed;
                    processingBar.Visibility      = Visibility.Visible;
                    processingBar.IsIndeterminate = false;
                    processingBar.Value           = processingBar.Maximum;
                });
            });
        }