Click here to Skip to main content
15,905,913 members
Home / Discussions / C#
   

C#

 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
Luc Pattyn14-Feb-11 8:13
sitebuilderLuc Pattyn14-Feb-11 8:13 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 8:21
MacRaider414-Feb-11 8:21 
AnswerRe: Report Progress from a class with a backgroundWorker Pin
Ian Shlasko14-Feb-11 8:11
Ian Shlasko14-Feb-11 8:11 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 8:28
MacRaider414-Feb-11 8:28 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
Ian Shlasko14-Feb-11 9:31
Ian Shlasko14-Feb-11 9:31 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 9:46
MacRaider414-Feb-11 9:46 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
Ian Shlasko14-Feb-11 12:11
Ian Shlasko14-Feb-11 12:11 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
DaveyM6914-Feb-11 11:24
professionalDaveyM6914-Feb-11 11:24 
Ian Shlasko wrote:
I wonder if the BackgroundWorker only allows ReportProgress to be called during the DoWork


No, internally it uses a SendOrPostCallback delegate and an AsyncOperation. If the AsyncOperation is null (there is no active worker thread) then the delegate is called directly. If it's not null then the AsyncOperation's Post method is called with the delegate and args as parameters which automatically invokes it on the syncronization context that RunWorkerAsync existed in.

C#
public void ReportProgress(int percentProgress, object userState)
{
    if (!this.WorkerReportsProgress)
    {
        throw new InvalidOperationException(SR.GetString("BackgroundWorker_WorkerDoesntReportProgress"));
    }
    ProgressChangedEventArgs arg = new ProgressChangedEventArgs(percentProgress, userState);
    if (this.asyncOperation != null)
    {
        this.asyncOperation.Post(this.progressReporter, arg);
    }
    else
    {
        this.progressReporter(arg);
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



QuestionSet a picture transparently in the foreground Pin
Mschauder14-Feb-11 2:21
Mschauder14-Feb-11 2:21 
AnswerRe: Set a picture transparently in the foreground Pin
musefan14-Feb-11 3:03
musefan14-Feb-11 3:03 
GeneralRe: Set a picture transparently in the foreground Pin
Mschauder14-Feb-11 3:15
Mschauder14-Feb-11 3:15 
GeneralRe: Set a picture transparently in the foreground Pin
musefan14-Feb-11 3:42
musefan14-Feb-11 3:42 
GeneralRe: Set a picture transparently in the foreground Pin
Mschauder14-Feb-11 22:08
Mschauder14-Feb-11 22:08 
Questiondirectory path Pin
arkiboys13-Feb-11 22:12
arkiboys13-Feb-11 22:12 
AnswerRe: directory path Pin
Pete O'Hanlon13-Feb-11 22:17
mvePete O'Hanlon13-Feb-11 22:17 
GeneralRe: directory path Pin
arkiboys13-Feb-11 22:23
arkiboys13-Feb-11 22:23 
GeneralRe: directory path Pin
Pete O'Hanlon13-Feb-11 22:45
mvePete O'Hanlon13-Feb-11 22:45 
GeneralRe: directory path Pin
arkiboys13-Feb-11 23:22
arkiboys13-Feb-11 23:22 
AnswerRe: directory path Pin
Dalek Dave14-Feb-11 0:14
professionalDalek Dave14-Feb-11 0:14 
AnswerRe: directory path Pin
GenJerDan14-Feb-11 0:29
GenJerDan14-Feb-11 0:29 
GeneralRe: directory path Pin
Pete O'Hanlon14-Feb-11 0:34
mvePete O'Hanlon14-Feb-11 0:34 
AnswerRe: directory path Pin
Luc Pattyn14-Feb-11 1:01
sitebuilderLuc Pattyn14-Feb-11 1:01 
AnswerRe: directory path Pin
PIEBALDconsult14-Feb-11 2:00
mvePIEBALDconsult14-Feb-11 2:00 
QuestionCon open wait Pin
Ajay Kale New13-Feb-11 22:01
Ajay Kale New13-Feb-11 22:01 
AnswerRe: Con open wait Pin
Pete O'Hanlon13-Feb-11 22:13
mvePete O'Hanlon13-Feb-11 22:13 

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.