Solved

using the progress bar?

Posted on 2008-06-20
8
277 Views
Last Modified: 2013-12-16
I have the following code:

 private void ProcessSpreadSheet ()
        {
            Excel.Application xlApp = null; //  Excel application object
            Excel.Workbook xlWorkBook = null; //  Excel Workbook object
            Excel.Worksheet xlWorkSheet = null; //  Excel Worksheet object
            Excel.Range inputRange = null; //  Excel Worksheet Range object
            int rowCount = 0, currRow = 0; //  row iterator
            string gradeName = null; //  character input variables
            decimal Price = 0.00M; //  price as a decimal number
            Excel.Range cellPriceValue = null;
            Excel.Range cellGradeValue = null;
            Excel.Range cellDiscountValue = null;
            bool WheatIndicatorFlag = false;
            bool DurumIndicatorFlag = false;
            bool BarleyIndicatorFlag = false;
            bool DesBarleyIndicatorFlag = false;
            bool WarningErrorTab = false;

            decimal?[,] discounts = new decimal?[4, 3];
            string[,] discountnames = new string[4,3] { {"WheatTough", "WheatDamp", "WheatStone"},  
                                           {"DurumTough", "DurumDamp", "DurumStone"},
                                           {"BarleyTough", "BarleyDamp", "BarleyStone"},
                                           {"DesBarleyTough", "DesBarleyDamp", "N/A"} };
             
            int pricesColumn = 0;
            int count_rows = 0;
            decimal sum_prices = 0.00M;
            InitialPrices.InitialPriceReportingServiceWS.PriceListHeaderObject PLHO = new InitialPrices.InitialPriceReportingServiceWS.PriceListHeaderObject();
            PLHO.price_list_hdr_id = dr["PRICE_LIST_HDR_ID"].ToString();
                         
         
            //  Define the input SS and open the 1st worksheet
            xlApp = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(InputFileName.Text, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            xlWorkSheet = ((Excel.Worksheet)(xlWorkBook.Worksheets.get_Item(1)));

            //  Store the rows and columns used in the input SS into inputRange
            inputRange = xlWorkSheet.UsedRange;

            //  Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0)
            //  Data of interest is in columns O and R (numbered 15 and 18 respectively)
            //  Initial prices load file has the prices in column 16
           
            //  All other load files have their prices in column 18
            if (rbtnInitialPriceOption.Checked)
            {
                pricesColumn = 16;
            }
            else
            {
                pricesColumn = 18;
            }

            for (rowCount = 10; rowCount <= inputRange.Rows.Count; rowCount++)
            {
                //  Read the grade name and price
                //  skip rows where the grade name is empty
                //  validate each line, if invalid, call an write_error function, passing in rowCount, grade name, price, E/W flag, and ErrMsg
                bool ErrorCheck = false;
                try
                {
                    cellPriceValue = ((Excel.Range)(inputRange.Cells[rowCount, pricesColumn]));
                    bool CheckNumeric = IsNumeric(cellPriceValue.Value2.ToString());
                   
                    if (cellPriceValue.Value2.ToString().Length > 0 || cellPriceValue.Value2 != null)
                    {
                        if (cellPriceValue.Value2.ToString() == "Stones" || cellPriceValue.Value2.ToString() == "Tough")
                        {
                            currRow = rowCount + 1; //  skip a row to where the discounts are
                            break;
                        }

                        cellGradeValue = ((Excel.Range)(inputRange.Cells[rowCount, 15]));
                        gradeName = (cellGradeValue.Value2.ToString().Trim());

                        InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WS = new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService();
                        int GradeCodeDetailID = 0;
                        string Status = null;
                        string GradePoolCode = null;

                         
                        WS.GetGradeCodeDetailID(gradeName, ref  GradeCodeDetailID, ref GradePoolCode, ref Status);

                        // Check grade code Id and set the indicator flags.
                        if (GradeCodeDetailID.ToString() == "01") // Wheat
                            WheatIndicatorFlag = true;
                        if (GradeCodeDetailID.ToString() == "02") // Durum
                            DurumIndicatorFlag = true;
                        if (GradeCodeDetailID.ToString() == "04") // Barley
                            BarleyIndicatorFlag = true;
                        if (GradeCodeDetailID.ToString() == "64") // DesBarley
                            DesBarleyIndicatorFlag = true;

                        if (CheckNumeric)
                        {
                            Price = decimal.Parse(cellPriceValue.Value2.ToString());//
                            sum_prices += Price;
                         
                        }
                        else
                        {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(),
                                GradeCodeDetailID, rowCount + 1, gradeName, null, 'E',
                                "Price contains a non-numeric value.");
                            ErrorCheck = true;
                            WarningErrorTab = true;
                        }

                       
                         
                       

                        if (GradeCodeDetailID == -1)
                        {
                             InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                             "Grade Code not found in Grade Code Details table.");
                             ErrorCheck = true;
                             WarningErrorTab = true;
                        }
                           
                        if ((Price) < 0.00M)
                        {
                              InsertPriceListLoadError(PLHO.price_list_hdr_id.ToString(), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                                "Price cannot be negative.");
                              ErrorCheck = true;
                              WarningErrorTab = true;
                        }

                       
                         ///////////////////////
                           

                         // Look at warnings 'W'
                         if ((Price) > 1000.00M)
                         {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                                              Price, 'W', "Price is over $1000.00.  Please confirm with SP&P.");
                             WarningErrorTab = true;
                         }
                         if ((Price) == 0.00M)
                         {
                            InsertPriceListLoadError(PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                                              decimal.Parse((0.00).ToString()), 'W', "Grade has no price.  Please confirm with SP&P.");
                            WarningErrorTab = true;
                         }

                         InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WSPLDO =
                             new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService();
                         InitialPrices.InitialPriceReportingServiceWS.PriceListDetailObject PLDO = new InitialPrices.InitialPriceReportingServiceWS.PriceListDetailObject();
                         PLDO.grade_code_dtl_id = GradeCodeDetailID;
                         PLDO.price_list_hdr_id = dr["PRICE_LIST_HDR_ID"].ToString();
                         PLDO.strght_price_amt = Price;
                         WSPLDO.InsertPriceDetail(PLDO, ref Status);
                         count_rows += 1;
                           
                                       
                        }
                     
                    }

                   catch
                   {
                      // Console.WriteLine("Blank Price encountered.  Likely a blank row.");
                   }

            }

How can I implemnt the backgroundWorker around this
 backgroundWorker1.RunWorkerAsync();
timer1.Start();


0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 12

Expert Comment

by:topdog770
ID: 21831801
I included your code in my example, even it's almost all commmented out.

I also show how to handle an error condition.

Please let me know if you have questions
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsApplication1
{
    public partial class Form1 :Form
    {
        BackgroundWorker _bw = new BackgroundWorker( );
        public Form1()
        {
            InitializeComponent( );
 
            _bw.WorkerSupportsCancellation = false; // don't allow/support cancelling
            _bw.WorkerReportsProgress = true;
            _bw.DoWork += new DoWorkEventHandler( BackgroundWorker_DoWork );
            _bw.ProgressChanged += new ProgressChangedEventHandler( BackgroundWorker_ProgressChanged );
            _bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler( BackgroundWork_WorkIsComplete );
        }
 
        void BackgroundWork_WorkIsComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                // response to a canceled job here
            }
 
            // WE CAN'T USE THIS VALUE SO...
            if (e.Error != null)
            {  // there was an error.. handle it here
 
            }
 
            this.tbMsg.Text = "Completed Successfullly";
            if (e.Result != null)
            {  // you can return result of the work here
                if (e.Result is DivideByZeroException)
                { // we know an error occurred!
                    tbMsg.Text = "Error: " + ((DivideByZeroException)e.Result).ToString( );
                }
            }
        }
 
        void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.pb.Value = e.ProgressPercentage;
            WorkerStatus ws = e.UserState as WorkerStatus;
            if (ws != null)
            {
                this.tbMsg.Text = ws.Msg;
            }
        }
 
        void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // adding object to convey status info back to form
            WorkerStatus workStatus = new WorkerStatus( );
 
 
            Excel.Application xlApp = null; //  Excel application object
            Excel.Workbook xlWorkBook = null; //  Excel Workbook object
            Excel.Worksheet xlWorkSheet = null; //  Excel Worksheet object
            Excel.Range inputRange = null; //  Excel Worksheet Range object
            int rowCount = 0, currRow = 0; //  row iterator 
            string gradeName = null; //  character input variables
            decimal Price = 0.00M; //  price as a decimal number
            Excel.Range cellPriceValue = null;
            Excel.Range cellGradeValue = null;
            Excel.Range cellDiscountValue = null;
            bool WheatIndicatorFlag = false;
            bool DurumIndicatorFlag = false;
            bool BarleyIndicatorFlag = false;
            bool DesBarleyIndicatorFlag = false;
            bool WarningErrorTab = false;
 
            decimal?[ , ] discounts = new decimal?[ 4, 3 ];
            string[ , ] discountnames = new string[ 4, 3 ] { {"WheatTough", "WheatDamp", "WheatStone"},  
                                           {"DurumTough", "DurumDamp", "DurumStone"}, 
                                           {"BarleyTough", "BarleyDamp", "BarleyStone"},
                                           {"DesBarleyTough", "DesBarleyDamp", "N/A"} };
 
            int pricesColumn = 0;
            int count_rows = 0;
            decimal sum_prices = 0.00M;
 
            workStatus.Msg = "Initializing Objects";
            _bw.ReportProgress( 2, workStatus );
 
 
            //InitialPrices.InitialPriceReportingServiceWS.PriceListHeaderObject PLHO = new InitialPrices.InitialPriceReportingServiceWS.PriceListHeaderObject( );
            //PLHO.price_list_hdr_id = dr[ "PRICE_LIST_HDR_ID" ].ToString( );
 
 
            //  Define the input SS and open the 1st worksheet
            xlApp = new Excel.Application( );
            xlWorkBook = xlApp.Workbooks.Open( e.Argument.ToString( ), Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing );
            xlWorkSheet = ((Excel.Worksheet)(xlWorkBook.Worksheets.get_Item( 1 )));
 
            //  Store the rows and columns used in the input SS into inputRange
            inputRange = xlWorkSheet.UsedRange;
 
            //  Read all used rows in the input SS, starting at the 11th row (rows are numbered from 0)
            //  Data of interest is in columns O and R (numbered 15 and 18 respectively)
            //  Initial prices load file has the prices in column 16
 
            //  All other load files have their prices in column 18
            //if (rbtnInitialPriceOption.Checked)
            //{
            //    pricesColumn = 16;
            //}
            //else
            //{
            //    pricesColumn = 18;
            //}
 
 
 
            for (rowCount = 0; rowCount < 25; rowCount++)
            {
                workStatus.Msg = "Processing Rows " + rowCount + " of 25";
                _bw.ReportProgress( 2 + rowCount, workStatus );
 
 
                // TO HANDLE ERROR... 
 
                try
                {
                    int zero = 0;
                    double d = 1 / zero;
                }
                catch (DivideByZeroException dze)
                {
                    e.Result = dze;
                    return;
                }
 
                //for (rowCount = 10; rowCount <= inputRange.Rows.Count; rowCount++)
                //{
                //    //  Read the grade name and price
                //    //  skip rows where the grade name is empty
                //    //  validate each line, if invalid, call an write_error function, passing in rowCount, grade name, price, E/W flag, and ErrMsg
                bool ErrorCheck = false;
                try
                {
                    //        cellPriceValue = ((Excel.Range)(inputRange.Cells[ rowCount, pricesColumn ]));
                    //        bool CheckNumeric = IsNumeric( cellPriceValue.Value2.ToString( ) );
 
                    //        if (cellPriceValue.Value2.ToString( ).Length > 0 || cellPriceValue.Value2 != null)
                    //        {
                    //            if (cellPriceValue.Value2.ToString( ) == "Stones" || cellPriceValue.Value2.ToString( ) == "Tough")
                    //            {
                    //                currRow = rowCount + 1; //  skip a row to where the discounts are
                    //                break;
                    //            }
 
                    //            cellGradeValue = ((Excel.Range)(inputRange.Cells[ rowCount, 15 ]));
                    //            gradeName = (cellGradeValue.Value2.ToString( ).Trim( ));
 
                    //            InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WS = new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService( );
                    //            int GradeCodeDetailID = 0;
                    //            string Status = null;
                    //            string GradePoolCode = null;
 
 
                    //            WS.GetGradeCodeDetailID( gradeName, ref  GradeCodeDetailID, ref GradePoolCode, ref Status );
 
                    //            // Check grade code Id and set the indicator flags.
                    //            if (GradeCodeDetailID.ToString( ) == "01") // Wheat
                    //                WheatIndicatorFlag = true;
                    //            if (GradeCodeDetailID.ToString( ) == "02") // Durum
                    //                DurumIndicatorFlag = true;
                    //            if (GradeCodeDetailID.ToString( ) == "04") // Barley
                    //                BarleyIndicatorFlag = true;
                    //            if (GradeCodeDetailID.ToString( ) == "64") // DesBarley
                    //                DesBarleyIndicatorFlag = true;
 
                    //            if (CheckNumeric)
                    //            {
                    //                Price = decimal.Parse( cellPriceValue.Value2.ToString( ) );//
                    //                sum_prices += Price;
 
                    //            }
                    //            else
                    //            {
                    //                InsertPriceListLoadError( PLHO.price_list_hdr_id.ToString( ),
                    //                    GradeCodeDetailID, rowCount + 1, gradeName, null, 'E',
                    //                    "Price contains a non-numeric value." );
                    //                ErrorCheck = true;
                    //                WarningErrorTab = true;
                    //            }
 
 
 
 
 
                    //            if (GradeCodeDetailID == -1)
                    //            {
                    //                InsertPriceListLoadError( PLHO.price_list_hdr_id.ToString( ), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                    //                "Grade Code not found in Grade Code Details table." );
                    //                ErrorCheck = true;
                    //                WarningErrorTab = true;
                    //            }
 
                    //            if ((Price) < 0.00M)
                    //            {
                    //                InsertPriceListLoadError( PLHO.price_list_hdr_id.ToString( ), GradeCodeDetailID, rowCount + 1, gradeName, Price, 'E',
                    //                  "Price cannot be negative." );
                    //                ErrorCheck = true;
                    //                WarningErrorTab = true;
                    //            }
 
 
                    //            ///////////////////////
 
 
                    //            // Look at warnings 'W'
                    //            if ((Price) > 1000.00M)
                    //            {
                    //                InsertPriceListLoadError( PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                    //                                  Price, 'W', "Price is over $1000.00.  Please confirm with SP&P." );
                    //                WarningErrorTab = true;
                    //            }
                    //            if ((Price) == 0.00M)
                    //            {
                    //                InsertPriceListLoadError( PLHO.price_list_hdr_id, GradeCodeDetailID, rowCount + 1, gradeName,
                    //                                  decimal.Parse( (0.00).ToString( ) ), 'W', "Grade has no price.  Please confirm with SP&P." );
                    //                WarningErrorTab = true;
                    //            }
 
                    //            InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WSPLDO =
                    //                new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService( );
                    //            InitialPrices.InitialPriceReportingServiceWS.PriceListDetailObject PLDO = new InitialPrices.InitialPriceReportingServiceWS.PriceListDetailObject( );
                    //            PLDO.grade_code_dtl_id = GradeCodeDetailID;
                    //            PLDO.price_list_hdr_id = dr[ "PRICE_LIST_HDR_ID" ].ToString( );
                    //            PLDO.strght_price_amt = Price;
                    //            WSPLDO.InsertPriceDetail( PLDO, ref Status );
                    //            count_rows += 1;
 
 
                    //        }
 
                }
 
                catch
                {
                    // Console.WriteLine("Blank Price encountered.  Likely a blank row.");
                }
            }
        }
 
        private void ProcessSpreadSheet()
        {
        }
 
        private bool IsNumeric(string p)
        {
            return true;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Close( );
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            string fileName = @"c:\example.xls";
 
            if (!_bw.IsBusy)
            {  // simple approach to not allowing duplicate calls to a busy worker thread
                _bw.RunWorkerAsync( fileName );
            }
        }
 
 
 
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
 
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose( );
            }
            base.Dispose( disposing );
        }
 
        #region Windows Form Designer generated code
 
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.pb = new System.Windows.Forms.ProgressBar( );
            this.tbMsg = new System.Windows.Forms.TextBox( );
            this.button1 = new System.Windows.Forms.Button( );
            this.button2 = new System.Windows.Forms.Button( );
            this.SuspendLayout( );
            // 
            // pb
            // 
            this.pb.Location = new System.Drawing.Point( 12, 72 );
            this.pb.Name = "pb";
            this.pb.Size = new System.Drawing.Size( 268, 23 );
            this.pb.TabIndex = 0;
            // 
            // tbMsg
            // 
            this.tbMsg.Location = new System.Drawing.Point( 12, 46 );
            this.tbMsg.Name = "tbMsg";
            this.tbMsg.Size = new System.Drawing.Size( 268, 20 );
            this.tbMsg.TabIndex = 1;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point( 104, 103 );
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size( 75, 23 );
            this.button1.TabIndex = 2;
            this.button1.Text = "OK";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler( this.button1_Click );
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point( 104, 17 );
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size( 75, 23 );
            this.button2.TabIndex = 3;
            this.button2.Text = "Go!";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler( this.button2_Click );
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size( 292, 129 );
            this.Controls.Add( this.button2 );
            this.Controls.Add( this.button1 );
            this.Controls.Add( this.tbMsg );
            this.Controls.Add( this.pb );
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout( false );
            this.PerformLayout( );
        }
 
        #endregion
 
        private System.Windows.Forms.ProgressBar pb;
        private System.Windows.Forms.TextBox tbMsg;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
    }
 
    public class WorkerStatus
    {
        // can add anything else you want here
        public string Msg = "";
    }
 
    public class InsertPriceListLoadError
    {
        public InsertPriceListLoadError(object p, int GradeCodeDetailID, int p_3, string gradeName, decimal p_5, char p_6, string p_7)
        {
 
        }
    }
 
}

Open in new window

0
 

Author Comment

by:mathieu_cupryk
ID: 21832637
I am confused on the name of this
void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
  you change it?
0
 
LVL 12

Expert Comment

by:topdog770
ID: 21832668
Oh, sorry.  

I just created an event handler called BackgroundWorker_DoWork that gets called when you call the _bw.RunWorkerAsync function.

when this line in the program is called:

_bw.RunWorkerAsync( fileName );

this function is started, BackgroundWorker_DoWork
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:mathieu_cupryk
ID: 21832738
I am still confused how am I suppsose to call my ProcessExcll
0
 
LVL 12

Accepted Solution

by:
topdog770 earned 500 total points
ID: 21832883
Ok.. let's start at the beginning.

1. Clicking on the button with text of "Go!" calls this function
========================================
        private void button2_Click(object sender, EventArgs e)
        {

2. We set the name of the file we want to process
========================================
            string fileName = @"c:\example.xls";

3. We check to make sure the BackgroundWorker thread isn't busy
========================================

            if (!_bw.IsBusy)
            {  // simple approach to not allowing duplicate calls to a busy worker thread

4. If it's not busy we tell the BackgroundWorker thread to start working  ========================================
                _bw.RunWorkerAsync( fileName );
            }
        }

5. This line of code -->  _bw.RunWorkerAsync( fileName );
Causes our "BackgroundWorker_DoWork" function to be called
========================================

6.  I took the code from your ProcessSpreadSheet() function and
put it in the BackgroundWorker_DoWork
========================================

7.  I commented out most of your code and add two pieces of code
========================================

This part to show how to send a progress message to your Form
-------------------
workStatus.Msg = "Processing Rows " + rowCount + " of 25";
_bw.ReportProgress( 2 + rowCount, workStatus );

This part to show how one approach to handling an error condition during the processing of an excel file-------------------
// TO HANDLE ERROR...
 
                try
                {
                    int zero = 0;
                    double d = 1 / zero;
                }
                catch (DivideByZeroException dze)
                {
                    e.Result = dze;
                    return;
                }

8.  If you haven't already, please create a new project and copy the code snippet I added.
     This code snippet is complete, I included code that's created by the designer and the code that normally gets added to the program.cs file.

If you step through the code in the debugger, you'll see how each function is called and how the progress and result information gets from the back ground work thread... back into the form

0
 

Author Comment

by:mathieu_cupryk
ID: 21835579
 WorkerStatus ws = e.UserState as WorkerStatus;
          Error      2      The type or namespace name 'WorkerStatus' could not be found (are you missing a using directive or an assembly reference?)      C:\SvnWork\InitialPriceReporting\DotNet\InitialPriceReporting\Form1.cs      98      13      InitialPriceReporting
0
 

Author Comment

by:mathieu_cupryk
ID: 21869184
tod, do you have an email that I can send my stuff.
0
 
LVL 12

Expert Comment

by:topdog770
ID: 21869567
The WorkerStatus is a very simple class atttached to the bottom of the original code snippet.  

I included it so you could see how you can pass most anything back to the main thread when the BackgroundWorker thread is complete.

Sure, send to to michaell770 at hotmail.com
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question