Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@ -326,13 +326,12 @@ namespace System.Threading {
[Obsolete ("Deprecated in favor of GetApartmentState, SetApartmentState and TrySetApartmentState.")]
public ApartmentState ApartmentState {
get {
if ((ThreadState & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
ValidateThreadState ();
return (ApartmentState)Internal.apartment_state;
}
set {
ValidateThreadState ();
TrySetApartmentState (value);
}
}
@ -368,14 +367,12 @@ namespace System.Threading {
public bool IsBackground {
get {
ThreadState thread_state = GetState (Internal);
if ((thread_state & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
return (thread_state & ThreadState.Background) != 0;
var state = ValidateThreadState ();
return (state & ThreadState.Background) != 0;
}
set {
ValidateThreadState ();
if (value) {
SetState (Internal, ThreadState.Background);
} else {
@ -649,6 +646,7 @@ namespace System.Threading {
public ApartmentState GetApartmentState ()
{
ValidateThreadState ();
return (ApartmentState)Internal.apartment_state;
}
@ -712,5 +710,13 @@ namespace System.Threading {
{
throw new PlatformNotSupportedException ();
}
ThreadState ValidateThreadState ()
{
var state = GetState (Internal);
if ((state & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
return state;
}
}
}