Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: User defined functions for Excel 2010 in .NET: args linked to cells don't work Pin
Dave Kreskowiak8-May-13 2:14
mveDave Kreskowiak8-May-13 2:14 
QuestionSolution Explorer to be shown on the toolbar Pin
indian1437-May-13 7:15
indian1437-May-13 7:15 
AnswerRe: Solution Explorer to be shown on the toolbar Pin
Dave Kreskowiak7-May-13 7:41
mveDave Kreskowiak7-May-13 7:41 
GeneralRe: Solution Explorer to be shown on the toolbar Pin
T Pat7-May-13 20:00
T Pat7-May-13 20:00 
AnswerRe: Solution Explorer to be shown on the toolbar Pin
Pete O'Hanlon7-May-13 8:16
mvePete O'Hanlon7-May-13 8:16 
AnswerRe: Solution Explorer to be shown on the toolbar Pin
Anna King8-May-13 3:07
professionalAnna King8-May-13 3:07 
GeneralRe: Solution Explorer to be shown on the toolbar Pin
Pete O'Hanlon8-May-13 3:47
mvePete O'Hanlon8-May-13 3:47 
QuestionBackground worker with progress bar timing issue Pin
Blubbo7-May-13 5:02
Blubbo7-May-13 5:02 
I've come across with this progress bar using worker.ReportProgress(). I was hoping to get a real-time progress Bar value from outside Write_Tag method. In this code below, it does seem to have some 1-2 seconds delay before showing the progress bar status.

Any suggesion?

C#
private void InitializeProgressBars()
{
   for (int i = 0; i < DevicePath.Count; i++)
   {
       progressBar[i] = new ProgressBar();
       progressBar[i].Location = new Point(3, 16);
       progressBar[i].Size = new Size(605, 31);
       progressBar[i].Maximum = 100;
    }

    gbProgressStatus0.Controls.Add(progressBar[0]);
    gbProgressStatus1.Controls.Add(progressBar[1]);
    gbProgressStatus2.Controls.Add(progressBar[2]);
    gbProgressStatus3.Controls.Add(progressBar[3]);
}

private void InitializeBackgroundWorkers()
{
    for (var f = 0; f < DevicePath.Count; f++)
    {
       bw[f] = new BackgroundWorker();
       bw[f].WorkerReportsProgress = true;
       bw[f].WorkerSupportsCancellation = true;
 
       switch (f)
       {
          case 0:
          {
              bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork0);
              bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted0);
              break;
          }
          case 1:
          {
              bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork1);
              bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted1);
              break;
          }
          case 2:
          {
              bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork2);
              bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted2);
              break;
           }
           case 3:
           {
              bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork3);
              bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted3);
              break;
           }
        }
     }

     bw[0].ProgressChanged += (sender, e) => { progressBar[0].Value = e.ProgressPercentage; };
     bw[1].ProgressChanged += (sender, e) => { progressBar[1].Value = e.ProgressPercentage; };
     bw[2].ProgressChanged += (sender, e) => { progressBar[2].Value = e.ProgressPercentage; };
     bw[3].ProgressChanged += (sender, e) => { progressBar[3].Value = e.ProgressPercentage; };
}


private void BackgroundWorkerFilesDoWork0(object sender, DoWorkEventArgs e)
{
   BackgroundWorker worker = sender as BackgroundWorker;
   ProgressBar pb = new ProgressBar();
   pb.Maximum = 100;
   worker.ReportProgress(0);
            
   System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
   sw.Start();
   int status = tag_device0.Write_Tag(0, writeDat, en_statusDat, pb);

   worker.ReportProgress(pb.Value);

   if (ReadTag)
   {
       worker.ReportProgress(0);
       byte[] tagData = new byte[1024];
       tag5_device0.Read_Tag(0, 0, tagData .Length, ref tagData , pb);
       worker.ReportProgress(pb.Value);
    }

    sw.Stop();
    string result = string.Format("Status: {0}    Elapsed: {1}", status, sw.Elapsed.ToString());
    e.Result = result;
}

AnswerRe: Background worker with progress bar timing issue Pin
Eddy Vluggen7-May-13 9:28
professionalEddy Vluggen7-May-13 9:28 
AnswerRe: Background worker with progress bar timing issue Pin
Matt T Heffron7-May-13 11:31
professionalMatt T Heffron7-May-13 11:31 
GeneralRe: Background worker with progress bar timing issue Pin
Blubbo8-May-13 8:18
Blubbo8-May-13 8:18 
SuggestionRe: Background worker with progress bar timing issue Pin
Matt T Heffron8-May-13 8:50
professionalMatt T Heffron8-May-13 8:50 
GeneralRe: Background worker with progress bar timing issue Pin
Blubbo8-May-13 9:11
Blubbo8-May-13 9:11 
Questionnetwork programming Pin
Member 100297487-May-13 4:53
Member 100297487-May-13 4:53 
AnswerRe: network programming Pin
Richard MacCutchan7-May-13 4:59
mveRichard MacCutchan7-May-13 4:59 
GeneralRe: network programming Pin
Ennis Ray Lynch, Jr.7-May-13 7:33
Ennis Ray Lynch, Jr.7-May-13 7:33 
GeneralRe: network programming Pin
Richard MacCutchan7-May-13 20:34
mveRichard MacCutchan7-May-13 20:34 
AnswerRe: network programming Pin
Anna King8-May-13 3:19
professionalAnna King8-May-13 3:19 
QuestionEthernet Port C# Pin
Member 100344047-May-13 2:28
Member 100344047-May-13 2:28 
AnswerRe: Ethernet Port C# Pin
Richard MacCutchan7-May-13 2:51
mveRichard MacCutchan7-May-13 2:51 
QuestionSaving objects with Cross-reference Pin
larsp7777-May-13 1:35
larsp7777-May-13 1:35 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen7-May-13 9:22
professionalEddy Vluggen7-May-13 9:22 
GeneralRe: Saving objects with Cross-reference Pin
larsp7777-May-13 12:14
larsp7777-May-13 12:14 
GeneralRe: Saving objects with Cross-reference Pin
Bernhard Hiller7-May-13 22:56
Bernhard Hiller7-May-13 22:56 
GeneralRe: Saving objects with Cross-reference Pin
larsp7778-May-13 2:24
larsp7778-May-13 2:24 

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.