Click here to Skip to main content
15,890,506 members
Home / Discussions / C#
   

C#

 
QuestionHow to update progressBar from another class Pin
MichCl15-Jan-13 4:17
MichCl15-Jan-13 4:17 
SuggestionRe: How to update progressBar from another class Pin
HuorSwords15-Jan-13 5:50
HuorSwords15-Jan-13 5:50 
GeneralRe: How to update progressBar from another class Pin
MichCl15-Jan-13 7:47
MichCl15-Jan-13 7:47 
GeneralRe: How to update progressBar from another class Pin
Dave Kreskowiak15-Jan-13 8:03
mveDave Kreskowiak15-Jan-13 8:03 
GeneralRe: How to update progressBar from another class Pin
Jibesh15-Jan-13 8:54
professionalJibesh15-Jan-13 8:54 
GeneralRe: How to update progressBar from another class Pin
MichCl15-Jan-13 9:00
MichCl15-Jan-13 9:00 
GeneralRe: How to update progressBar from another class Pin
Jibesh15-Jan-13 9:09
professionalJibesh15-Jan-13 9:09 
GeneralRe: How to update progressBar from another class Pin
Jibesh15-Jan-13 9:24
professionalJibesh15-Jan-13 9:24 
Ok I will try to explain with your class name

define a event in your interface iCR.cs
C#
public delegate void ProgressChangeHandler(int progress);

interface CRInterface
{
  event ProgressChangeHandler ProgressChanged;
  int ProcessTWriting(ref byte[] WDat, ref int pb_value)
}

Implement this interface in CRD.cs class
C#
class MyCR: CRInterface
{
  public event ProgressChangeHandler ProgressChanged;
  
  public int ProcessTWriting(ref byte[] WDat, ref int pb_value)
  {
    status = AttemptWrites(ref pb_value);
  } 
  
  private int AttemptWrites(ref int pb_value)
  {
     for (int i = 0; i < ((wDat.Length) / 4); i++)
     {
        RaiseProgressChange(i);
        //as it does writes, I want to set pb_value here to % complete
     }
  }
  
   private void RaiseProgressChange(int progress)
   {
     if(ProgressChanged!= null)
     {
       ProgressChanged(progress);
     }
   }
}

Finally Subscribe for event change in your FormClass i.e PC.cs
C#
// call this line just below where you create the instance of CR5 class
private FormLoad(...)
{
  cr.ProgressChanged += new ProgressChangeHandler(CR_ProgressChanged);
}

private void CR_ProgressChanged(int progress)
{
  progressBar.Value = progress;
}

Hope this helps.
Jibesh V P

GeneralRe: How to update progressBar from another class Pin
MichCl15-Jan-13 9:55
MichCl15-Jan-13 9:55 
GeneralRe: How to update progressBar from another class Pin
Jibesh15-Jan-13 10:06
professionalJibesh15-Jan-13 10:06 
GeneralRe: How to update progressBar from another class Pin
MichCl15-Jan-13 10:15
MichCl15-Jan-13 10:15 
GeneralRe: How to update progressBar from another class Pin
Jibesh15-Jan-13 11:34
professionalJibesh15-Jan-13 11:34 
GeneralRe: How to update progressBar from another class Pin
MichCl17-Jan-13 5:18
MichCl17-Jan-13 5:18 
GeneralRe: How to update progressBar from another class Pin
Jibesh17-Jan-13 8:17
professionalJibesh17-Jan-13 8:17 
GeneralRe: How to update progressBar from another class Pin
MichCl17-Jan-13 8:59
MichCl17-Jan-13 8:59 
GeneralRe: How to update progressBar from another class Pin
Jibesh17-Jan-13 9:18
professionalJibesh17-Jan-13 9:18 
GeneralRe: How to update progressBar from another class Pin
MichCl17-Jan-13 9:44
MichCl17-Jan-13 9:44 
GeneralRe: How to update progressBar from another class Pin
Jibesh17-Jan-13 10:24
professionalJibesh17-Jan-13 10:24 
GeneralRe: How to update progressBar from another class Pin
MichCl18-Jan-13 2:07
MichCl18-Jan-13 2:07 
GeneralRe: How to update progressBar from another class Pin
MichCl18-Jan-13 7:16
MichCl18-Jan-13 7:16 
GeneralRe: How to update progressBar from another class Pin
Jibesh18-Jan-13 13:55
professionalJibesh18-Jan-13 13:55 
GeneralRe: How to update progressBar from another class Pin
MichCl21-Jan-13 4:53
MichCl21-Jan-13 4:53 
GeneralRe: How to update progressBar from another class Pin
Jibesh21-Jan-13 5:00
professionalJibesh21-Jan-13 5:00 
GeneralRe: How to update progressBar from another class Pin
MichCl21-Jan-13 5:01
MichCl21-Jan-13 5:01 
GeneralRe: How to update progressBar from another class Pin
Jibesh21-Jan-13 5:02
professionalJibesh21-Jan-13 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.