2012-02-25 17 views
23

मैं इस BackgroundWorker बात
लिए नया हूँ मैं कैसे एक
बनाने के लिए इस बारे में कुछ लेख पढ़ा है क्या यह"यह पृष्ठभूमिवर्कर कहता है कि यह प्रगति की रिपोर्ट नहीं करता है।" - क्यूं कर?

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) 
    { 
     Bitmap imgbox = new Bitmap(pictureBox.Image); 

     int imgHeight = imgbox.Height; 
     int imgWidth = imgbox.Width; 

     int counter = 1; 

     MinMaxWidth = imgWidth - 50; 
     MaxWidth = imgWidth; 

     try 
     { 
      Color c; 
      //Color c2; 

      for (int i = 0; i < imgbox.Width; i++) 
      { 
       for (int j = 0; j < imgbox.Height; j++) 
       { 
        c = imgbox.GetPixel(i, j); 
        string cn = c.Name; 
        counter++; 
        backgroundWorker1.ReportProgress(counter); 
       } 
      } 
      MessageBox.Show("SUCESSFULLY DONE"); 
     } 
     catch (Exception ex) { MessageBox.Show(ex.Message); } 
    } 

    private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) 
    { 
     MyProgress.Value = e.ProgressPercentage; 
    } 

उत्पादित लेकिन जब मैं DoWork घटना शुरू कर दिया। यह त्रुटि

यह BackgroundWorker बताती है कि यह प्रगति की रिपोर्ट नहीं करता है।
WorkerReportsProgess संशोधित करें कि यह रिपोर्ट प्रगति करता है।

ijust का पालन करें क्या ट्यूटोरियल कहते
कि समस्या क्या होगा ?, वहाँ कुछ है कि मैं भूल गया है?

उत्तर

73

त्रुटि के अनुसार, WorkerReportsProgressBackgroundWorker घटक true पर सेट करें।