executioncontext

Wrong Thread.CurrentPrincipal in async WCF end-method

半城伤御伤魂 提交于 2019-12-03 06:30:42
I have a WCF service which has its Thread.CurrentPrincipal set in the ServiceConfiguration.ClaimsAuthorizationManager . When I implement the service asynchronously like this: public IAsyncResult BeginMethod1(AsyncCallback callback, object state) { // Audit log call (uses Thread.CurrentPrincipal) var task = Task<int>.Factory.StartNew(this.WorkerFunction, state); return task.ContinueWith(res => callback(task)); } public string EndMethod1(IAsyncResult ar) { // Audit log result (uses Thread.CurrentPrincipal) return ar.AsyncState as string; } private int WorkerFunction(object state) { // perform

JavaScript Scope and Execution Context

梦想的初衷 提交于 2019-12-01 06:00:54
I am trying to understand JavaScript scope rules. What I have read in textbooks and the documentation is confusing. It seems to me that JavaScript is a statically (or lexically) scoped language - when trying to bind a variable name to a variable (definition), the lexical structure of the code is used. An execution context seems to be similar to a stack frame on the call stack. Each execution context has a variable object upon which all the local variables (of the associated function) are defined. These variable objects are linked together to provide a 'scope chain' from the variable object at

JavaScript Scope and Execution Context

风流意气都作罢 提交于 2019-12-01 03:34:21
问题 I am trying to understand JavaScript scope rules. What I have read in textbooks and the documentation is confusing. It seems to me that JavaScript is a statically (or lexically) scoped language - when trying to bind a variable name to a variable (definition), the lexical structure of the code is used. An execution context seems to be similar to a stack frame on the call stack. Each execution context has a variable object upon which all the local variables (of the associated function) are

Using ASP.NET Web API, my ExecutionContext isn't flowing in async actions

纵然是瞬间 提交于 2019-11-28 06:24:43
I'm having difficulty understanding the mechanics behind ExecutionContext. From what I've read online, context-sensitive items such as security (Thread Principal), culture, etc, should flow across asynchronous threads within the bounds of an execution unit of work. I'm encountering very confusing and potentially dangerous bugs though. I'm noticing my thread's CurrentPrincipal is getting lost across async execution. Here is an example ASP.NET Web API scenario: First, let's setup a simple Web API configuration with two delegating handlers for testing purposes. All they do is write out debug

Using ASP.NET Web API, my ExecutionContext isn't flowing in async actions

若如初见. 提交于 2019-11-27 01:19:54
问题 I'm having difficulty understanding the mechanics behind ExecutionContext. From what I've read online, context-sensitive items such as security (Thread Principal), culture, etc, should flow across asynchronous threads within the bounds of an execution unit of work. I'm encountering very confusing and potentially dangerous bugs though. I'm noticing my thread's CurrentPrincipal is getting lost across async execution. Here is an example ASP.NET Web API scenario: First, let's setup a simple Web