Click here to Skip to main content
15,893,401 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to create a child process in C#? Pin
martingeorgiev1-Jun-10 5:31
martingeorgiev1-Jun-10 5:31 
GeneralRe: How to create a child process in C#? Pin
PIEBALDconsult1-Jun-10 5:44
mvePIEBALDconsult1-Jun-10 5:44 
Questiondisplaying progress bar in background worker thread C# Pin
evrajo31-May-10 23:32
evrajo31-May-10 23:32 
AnswerRe: displaying progress bar in background worker thread C# Pin
Pete O'Hanlon31-May-10 23:46
mvePete O'Hanlon31-May-10 23:46 
GeneralRe: displaying progress bar in background worker thread C# Pin
evrajo31-May-10 23:51
evrajo31-May-10 23:51 
GeneralRe: displaying progress bar in background worker thread C# Pin
evrajo1-Jun-10 0:05
evrajo1-Jun-10 0:05 
GeneralRe: displaying progress bar in background worker thread C# Pin
Pete O'Hanlon1-Jun-10 0:08
mvePete O'Hanlon1-Jun-10 0:08 
GeneralRe: displaying progress bar in background worker thread C# Pin
Pete O'Hanlon1-Jun-10 0:06
mvePete O'Hanlon1-Jun-10 0:06 
That would suggest you're using it in the wrong way. Here's a small sample demonstrating how to update a progress bar while a loop is incrementing,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace SampleBackgroundWorker
{
  public partial class MainForm : Form
  {
    private BackgroundWorker _worker = new BackgroundWorker();
    private static readonly object SyncLock = new object();
    public MainForm()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      _worker.WorkerReportsProgress = true;
      _worker.ProgressChanged += new 
        ProgressChangedEventHandler(ProgressChanged);
      _worker.DoWork += new DoWorkEventHandler(DoWork);
      _worker.RunWorkerAsync();
    }

    void DoWork(object sender, DoWorkEventArgs e)
    {
      for (int i = 1; i <= 10; i++)
      {
        lock (SyncLock)
        {
          Monitor.Wait(SyncLock, 1000);
        }
        _worker.ReportProgress(i * 10);
      }
    }

    void ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
      barProgress.Value = e.ProgressPercentage ;
    }
  }
}

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



AnswerRe: displaying progress bar in background worker thread C# Pin
DaveyM691-Jun-10 0:31
professionalDaveyM691-Jun-10 0:31 
AnswerRe: displaying progress bar in background worker thread C# Pin
PIEBALDconsult1-Jun-10 4:38
mvePIEBALDconsult1-Jun-10 4:38 
QuestionExcel Workbook Save copy error in Windows 2003 server Pin
kumuda.t31-May-10 23:27
kumuda.t31-May-10 23:27 
AnswerRe: Excel Workbook Save copy error in Windows 2003 server Pin
Henry Minute1-Jun-10 0:54
Henry Minute1-Jun-10 0:54 
Questionrecord voice and phone number of central phone device Pin
mr.mohsen31-May-10 21:53
mr.mohsen31-May-10 21:53 
QuestionHelp required in Threading.. Pin
NetMan201231-May-10 21:36
NetMan201231-May-10 21:36 
AnswerRe: Help required in Threading.. Pin
Stanciu Vlad31-May-10 21:46
Stanciu Vlad31-May-10 21:46 
AnswerRe: Help required in Threading.. Pin
mr.mohsen31-May-10 21:56
mr.mohsen31-May-10 21:56 
GeneralRe: Help required in Threading.. Pin
NetMan20121-Jun-10 1:14
NetMan20121-Jun-10 1:14 
GeneralRe: Help required in Threading.. Pin
#realJSOP1-Jun-10 1:41
mve#realJSOP1-Jun-10 1:41 
AnswerRe: Help required in Threading.. Pin
Mycroft Holmes31-May-10 21:57
professionalMycroft Holmes31-May-10 21:57 
AnswerRe: Help required in Threading.. Pin
Henry Minute1-Jun-10 0:57
Henry Minute1-Jun-10 0:57 
GeneralRe: Help required in Threading.. Pin
Luc Pattyn1-Jun-10 2:51
sitebuilderLuc Pattyn1-Jun-10 2:51 
GeneralRe: Help required in Threading.. Pin
Henry Minute1-Jun-10 3:09
Henry Minute1-Jun-10 3:09 
GeneralRe: Help required in Threading.. Pin
harold aptroot1-Jun-10 3:24
harold aptroot1-Jun-10 3:24 
GeneralRe: Help required in Threading.. Pin
Luc Pattyn1-Jun-10 3:51
sitebuilderLuc Pattyn1-Jun-10 3:51 
Questionremote debugging? Pin
swjam31-May-10 20:01
swjam31-May-10 20:01 

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.