Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@ -10,14 +10,12 @@ namespace System.ServiceModel
public sealed class OperationContextScope : IDisposable
{
[ThreadStatic]
static OperationContextScope currentScope;
static AsyncLocal<OperationContextScope> currentScope = new AsyncLocal<OperationContextScope>();
OperationContext currentContext;
bool disposed;
readonly OperationContext originalContext = OperationContext.Current;
readonly OperationContextScope originalScope = OperationContextScope.currentScope;
readonly Thread thread = Thread.CurrentThread;
readonly OperationContextScope originalScope = OperationContextScope.currentScope.Value;
public OperationContextScope(IContextChannel channel)
{
@ -41,22 +39,19 @@ namespace System.ServiceModel
void PushContext(OperationContext context)
{
this.currentContext = context;
OperationContextScope.currentScope = this;
OperationContextScope.currentScope.Value = this;
OperationContext.Current = this.currentContext;
}
void PopContext()
{
if (this.thread != Thread.CurrentThread)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInvalidContextScopeThread0)));
if (OperationContextScope.currentScope != this)
if (OperationContextScope.currentScope.Value != this)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxInterleavedContextScopes0)));
if (OperationContext.Current != this.currentContext)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxContextModifiedInsideScope0)));
OperationContextScope.currentScope = this.originalScope;
OperationContextScope.currentScope.Value = this.originalScope;
OperationContext.Current = this.originalContext;
if (this.currentContext != null)