Click here to Skip to main content
15,891,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: BackgroundWorker Pin
RugbyLeague12-Feb-10 4:01
RugbyLeague12-Feb-10 4:01 
GeneralRe: BackgroundWorker Pin
RugbyLeague12-Feb-10 4:31
RugbyLeague12-Feb-10 4:31 
AnswerRe: BackgroundWorker Pin
Luc Pattyn12-Feb-10 8:50
sitebuilderLuc Pattyn12-Feb-10 8:50 
GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 11:58
professionalDaveyM6912-Feb-10 11:58 
AnswerRe: BackgroundWorker Pin
Luc Pattyn12-Feb-10 12:28
sitebuilderLuc Pattyn12-Feb-10 12:28 
GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 12:38
professionalDaveyM6912-Feb-10 12:38 
GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 9:45
professionalDaveyM6912-Feb-10 9:45 
GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 10:19
professionalDaveyM6912-Feb-10 10:19 
Looking into the implementation in a little more detail, the reason you can't access Result if an exception is thrown is RunWorkerCompletedEventArgs derives from AsyncCompletedEventArgs. The RunWorkerCompletedEventArgs inplementation of Result is:
C#
public object Result { 
    get
    { 
        base.RaiseExceptionIfNecessary(); 
        return result; 
    } 
}
and the AsyncCompletedEventArgs.RaiseExceptionIfNecessary is:
C#
protected void RaiseExceptionIfNecessary() 
{ 
    if (Error != null)
    { 
        throw new TargetInvocationException(SR.GetString(SR.Async_ExceptionOccurred), Error); 
    } 
    else if (Cancelled)
    { 
        throw new InvalidOperationException(SR.GetString(SR.Async_OperationCancelled)); 
    }     
}
This doesn't solve your issue - but now you can see why it exists, and what you would need to change if you wanted to implement your own BackgroundWorker where Result is always available.
Dave

Tip: Passing values between objects using events (C#)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 11:56
professionalDaveyM6912-Feb-10 11:56 
AnswerRe: BackgroundWorker Pin
Luc Pattyn12-Feb-10 12:26
sitebuilderLuc Pattyn12-Feb-10 12:26 
GeneralRe: BackgroundWorker Pin
DaveyM6912-Feb-10 12:37
professionalDaveyM6912-Feb-10 12:37 
GeneralRe: BackgroundWorker Pin
Luc Pattyn12-Feb-10 12:47
sitebuilderLuc Pattyn12-Feb-10 12:47 
QuestionDocumentation description about the method and its parameters. Pin
Blubbo12-Feb-10 3:29
Blubbo12-Feb-10 3:29 
AnswerRe: Documentation description about the method and its parameters. Pin
R. Giskard Reventlov12-Feb-10 3:33
R. Giskard Reventlov12-Feb-10 3:33 
AnswerRe: Documentation description about the method and its parameters. Pin
dan!sh 12-Feb-10 3:36
professional dan!sh 12-Feb-10 3:36 
GeneralRe: Documentation description about the method and its parameters. Pin
Blubbo12-Feb-10 3:46
Blubbo12-Feb-10 3:46 
QuestionMultiPage-Application - Navigation Pin
PingOfDeath198312-Feb-10 3:09
PingOfDeath198312-Feb-10 3:09 
AnswerRe: MultiPage-Application - Navigation Pin
dan!sh 12-Feb-10 3:11
professional dan!sh 12-Feb-10 3:11 
QuestionAT command problem Pin
saeidfarahi12-Feb-10 2:44
saeidfarahi12-Feb-10 2:44 
AnswerRe: AT command problem Pin
Richard MacCutchan12-Feb-10 3:24
mveRichard MacCutchan12-Feb-10 3:24 
GeneralRe: AT command problem Pin
saeidfarahi12-Feb-10 3:28
saeidfarahi12-Feb-10 3:28 
GeneralRe: AT command problem Pin
Richard MacCutchan12-Feb-10 3:49
mveRichard MacCutchan12-Feb-10 3:49 
QuestionThread sychronization Pin
koleraba12-Feb-10 2:35
koleraba12-Feb-10 2:35 
AnswerRe: Hi Pin
Not Active12-Feb-10 4:07
mentorNot Active12-Feb-10 4:07 
GeneralRe: Hi Pin
koleraba12-Feb-10 5:31
koleraba12-Feb-10 5:31 

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.