Click here to Skip to main content
15,919,778 members
Home / Discussions / C#
   

C#

 
AnswerRe: Ending another process Pin
Pete O'Hanlon19-Sep-07 3:04
mvePete O'Hanlon19-Sep-07 3:04 
GeneralRe: Ending another process Pin
__DanC__19-Sep-07 3:06
__DanC__19-Sep-07 3:06 
AnswerRe: Ending another process Pin
Luc Pattyn19-Sep-07 6:00
sitebuilderLuc Pattyn19-Sep-07 6:00 
GeneralRe: Ending another process Pin
__DanC__19-Sep-07 6:02
__DanC__19-Sep-07 6:02 
GeneralRe: Ending another process Pin
Pete O'Hanlon19-Sep-07 9:58
mvePete O'Hanlon19-Sep-07 9:58 
GeneralRe: Ending another process Pin
martin_hughes19-Sep-07 12:43
martin_hughes19-Sep-07 12:43 
GeneralRe: Ending another process Pin
Pete O'Hanlon19-Sep-07 21:49
mvePete O'Hanlon19-Sep-07 21:49 
Questionpass progressBar control to function in a different class and thread Pin
gizmokaka19-Sep-07 2:46
gizmokaka19-Sep-07 2:46 
Hello to all.

My problem is, that I can't seem to understand how to pass the updating of my progressBar control to
the function it supposed to be updated by.
my function sits in a different class then my form and does some measurments that return values and
then it manipulates it for my bussiness needs.

the problem is that I want that function(called from a background worker thread in my form) that belongs to another class to be updating the progressBar on the form created in the main thread.

if I was inside the same thread background workerThread I don't have a problem using the reportProgress method, the problem is that start_ChannelA_Offsetting function belongs to another class

here is some relevant code, please help me...

private void frmPicoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            PICO.start_ChannelA_Offsetting(ref updateProgress);
            
            frmPicoBackgroundWorker.ReportProgress(updateProgress);

        } 


private void frmPicoBackgroundWorker_ProgressChanged(object Sender, ProgressChangedEventArgs e)
        {
            progressBarSampling.Step = updateProgress;
            progressBarSampling.PerformStep();
        }


public void start_ChannelA_Offsetting(ref int updateProgress)
      {
          if (!Opened)
          {
              MessageBox.Show("device is not opened!!!");
              return;
          }

          this.SetChannel(Channel_A, A_enabled, A_coupling, range);

          this.RunStreaming((short)timeIntervalMs, this.maxSamples, windowed);
          this.totNumOfSamples = (this.numValues / 2) * offsetChA.Length;
          //samplingProgBar.Maximum = Convert.ToInt32(totNumOfSamples - 1);
          //===============================================================================================
          //main loop for collection all values from PICO in the time instructed and saving them for 
          //later use inside a List collection.
          //====================================================================================================
          try
          {
              int i, j = 0, t;
              for (j = 0, t = 0; j < totNumOfSamples - 1 || t == offsetChA.Length; t++)
              {
                  Thread.Sleep((this.numValues / 2) * Convert.ToInt32(this.Intervalms));
                  values_collected = this.GetValues(bufferA, bufferB, bufferC, bufferD, out overflows, numValues);
                  //if (values_collected == 0)
                  //Console.WriteLine("returned 0");
                  if (values_collected < numValues / 2)
                  {
                      if (t >= 0)
                          t--;
                      continue;
                  }

                  updateProgress = Convert.ToInt32((j / totNumOfSamples) * 100);
                  //looping on values collected and collect to an array of mV
                  for (i = 0; i < values_collected; i++, j++)
                  {
                      if (j == totNumOfSamples - 1)
                      {
                          break;
                      }
                      bufferA_mV[i] = this.adc_to_mv(bufferA[i], realRange);
                  }
                  //make value after the 1st break not collected into offset, since no value in the bufferA_mV
                  //is entered as new.
                  if (i < values_collected - 1)
                      break;
                  //calculate the offset of all values_collected by summing them up and 
                  //devide by number of values collected. the result is the offset from 0
                  this.offsetChA[t] = (sumBuffer(bufferA_mV) / (double)(i));
              }
          }
          catch (Exception e)
          {
              MessageBox.Show("Finishing in an orederly fasion");
              Console.WriteLine(e);
              this.Stop();
          }
          if (Opened)
          {
              this.Stop();
              MessageBox.Show("finished all requested sampling");
          }
      }


all help will be most appreciated.
AnswerRe: pass progressBar control to function in a different class and thread Pin
gizmokaka19-Sep-07 4:04
gizmokaka19-Sep-07 4:04 
Questionhow to display a msg on leaving a page Pin
samerh19-Sep-07 2:29
samerh19-Sep-07 2:29 
AnswerRe: how to display a msg on leaving a page Pin
Guffa19-Sep-07 3:00
Guffa19-Sep-07 3:00 
QuestionPrevent cursor from leaving a control in WPF. Pin
Joakim Rosendahl19-Sep-07 2:29
Joakim Rosendahl19-Sep-07 2:29 
Questioncustom directshow filter Pin
Kuldeep Antil19-Sep-07 2:11
Kuldeep Antil19-Sep-07 2:11 
AnswerRe: custom directshow filter Pin
Jintal Patel19-Sep-07 20:03
Jintal Patel19-Sep-07 20:03 
GeneralRe: custom directshow filter Pin
Kuldeep Antil20-Sep-07 0:03
Kuldeep Antil20-Sep-07 0:03 
Questionhow transfer specified file via modem? Pin
samforu19-Sep-07 1:22
samforu19-Sep-07 1:22 
AnswerRe: how transfer specified file via modem? Pin
samforu20-Sep-07 0:14
samforu20-Sep-07 0:14 
QuestionUsing typedDataSet in c# 2005 Pin
himanshu p taunk19-Sep-07 1:10
himanshu p taunk19-Sep-07 1:10 
AnswerRe: Using typedDataSet in c# 2005 Pin
hjsabet19-Sep-07 3:51
hjsabet19-Sep-07 3:51 
QuestionHow to make phone calls from pc to mobile? Pin
anu8119-Sep-07 0:55
anu8119-Sep-07 0:55 
AnswerRe: How to make phone calls from pc to mobile? Pin
samforu19-Sep-07 1:28
samforu19-Sep-07 1:28 
QuestionRegarding Telnet urgent Pin
praveenkumar palla19-Sep-07 0:48
praveenkumar palla19-Sep-07 0:48 
AnswerRe: Regarding Telnet urgent Pin
Not Active19-Sep-07 2:24
mentorNot Active19-Sep-07 2:24 
QuestionRe: Regarding Telnet urgent Pin
praveenkumar palla19-Sep-07 3:10
praveenkumar palla19-Sep-07 3:10 
AnswerRe: Regarding Telnet urgent Pin
Not Active19-Sep-07 3:22
mentorNot Active19-Sep-07 3:22 

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.