c# - ConfigureAwait(true) is working only on 4.6 -


i ran following code on dot net framework 4.5, 4.5.1, 4.5.2 , 4.6

    public async task<int> printculturesasync()     {         thread.currentthread.currentuiculture = new cultureinfo("en-in");          console.writeline(thread.currentthread.managedthreadid);         console.writeline(thread.currentthread.currentuiculture);          await somemethod().configureawait(true);          console.writeline(thread.currentthread.managedthreadid);         console.writeline(thread.currentthread.currentuiculture);          return 1;     } 

i observed on framework 4.6, configureawait(true) working , showing same culture after await somemethod().configureawait(true) called. not supported on 4.5, 4.5.1 , 4.5.2 ?

that new feature in .net framework 4.6

see: task class (system.threading.tasks)

starting desktop apps target .net framework 4.6, culture of thread creates , invokes task becomes part of thread's context. is, regardless of current culture of thread on task executes, current culture of task culture of calling thread. apps target versions of .net framework prior .net framework 4.6, culture of task culture of thread on task executes. more information, see "culture , task-based asynchronous operations" section in cultureinfo topic. note store apps follow windows runtime in setting , getting default culture.

so newly spawned tasks same culture thread spawning.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -