c# - How To Force Thread Change in ASP.NET Core ProcessAsync in Tag Helper -


i'm trying put demonstration show processasync moves work off of running asp.net web server thread pool. wrote short example calls weather service. unfortunately threadid not change.

my understanding might not. so, 2 questions:

1: doing correctly , should expect threadidbefore , threadidafter should/might different?

2: assuming i'm doing correctly, there can make demo show new threadid?

namespace webapptaghelper.taghelpers {     public class mytesttaghelper : taghelper     {         private static httpclient _httpclient = new httpclient();          string requesturl = "http://samples.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=b1b15e88fa797225412429c1c50c122a1";         public override async task processasync(             taghelpercontext context, taghelperoutput output)         {             var threadidbefore = thread.currentthread.managedthreadid;             var uri = new uri(requesturl);             using (var response = await _httpclient.getasync(uri))             {                 response.ensuresuccessstatuscode();                  var result = await response.content.readasstringasync();                  jobject json = jobject.parse(result);                 if (result != null)                 {                     output.attributes.add("class", "highlight");                     var threadidafter = thread.currentthread.managedthreadid;                     output.content.sethtmlcontent(                         string.format("<b>thread id before: {0} after: {1}</b>", threadidbefore, threadidafter));                  }              }          }     }  } 

am doing correctly , should expect threadidbefore , threadidafter should/might different?

no. there's no await between "before" , "after", there's no possibility of thread change.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -