Is using await on the UI thread the same as a blocking call?
Tag : chash , By : John Miller
Date : March 29 2020, 07:55 AM
may help you . No, absolutely not. The point of await is that it doesn't block. Assuming the result of PrintTwoMillionTimes behaves sensibly, the async method will return immediately... but it will attach a continuation so that the rest of the method will execute (on the UI thread) when the result completes.
|
Why does a blocking thread consume more then async/await?
Date : March 29 2020, 07:55 AM
Hope this helps Well, let's imagine a web-server. Most of his time, all he does is wait. it doesn't really CPU-bound usually, but more of I/O bound. It waits for network I/O, disk I/O etc. After every time he waits, he has something (usually very short to do) and then all he does is waiting again. Now, the interesting part is what happend while he waits. In the most "trivial" case (that of course is absolutely not production), you would create a thread to deal with every socket you have. Now, each of those threads has it's own cost. Some handles, 1MB of stack space... And of course, not all those threads can run in the same time - so the OS scheduler need to deal with that and choose the right thread to run each time (which means A LOT of context switching). It will work for 1 clients. It'll work for 10 clients. But, let's imagine 10,000 clients at the same time. 10,000 threads means 10GB of memory. That's more than the average web server in the world.
|
blocking main thread on async/await
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The posted Read code is fine. The issue is in the consuming code. It's common to get a deadlock with async if you call Wait() or Result on the returned Task or its antecedent Task up in the call chain. As always in these cases, the general advice applies: don't block on async code. Once you start using async/await, you should be using async/await throughout your entire call chain. public Task<List<Category>> GetAllActiveCategoriesAsync(Guid siteGuid) {
return base.Read<Category>(SPNAME_GETALLACTIVE, siteGuid);
}
public async Task<List<Category>> GetAllActiveCategoriesAsync(Guid siteGuid) {
List<Category> result = await base.Read<Category>(SPNAME_GETALLACTIVE, siteGuid);
// Do something.
return result;
}
|
Is Await.ready really blocking main thread?
Tag : scala , By : user179190
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have a piece of code in Scala in which I use Await.ready in the main block and then use the corresponding value. val k = b.flatMap(x => {a.map(y => x+y)})
println("k = " + k)
|
await of async WCF call not returning to UI thread and/or blocking UI thread
Tag : chash , By : wiznick
Date : March 29 2020, 07:55 AM
|