Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What sets IsFaulted to false?

I understand that IsFaulted is property that can only be used with Get and what its use is for but I'm having trouble understanding if and when it is ever changed from true to false. Most sites I see online discuss what it is used for and maybe having a check for it but I don't see them ever changing it intentionally or through some kind of work around.

like image 377
user2920788 Avatar asked Dec 31 '25 20:12

user2920788


1 Answers

I suppose that you are talking about Task.IsFaulted.

It gets changed to true if there is an unhanded exception during the tasks' execution. Its state depends on the state flags set internally.

You can see from code of IsFaulted that there is no setter:

public bool IsFaulted 
{ 
    get
    { 
        // Faulted is "king" -- if that bit is present (regardless of other bits), we are faulted.
        return ((m_stateFlags & TASK_STATE_FAULTED) != 0);
    }
} 
like image 138
dee-see Avatar answered Jan 03 '26 10:01

dee-see



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!