You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder if the runtime will use new thread when a request comes. if so I think there is no difference between use or not useasync .
if there is function :
public async Task<int> Get(int id)
{
id = 0;
id= await db.Values.GetAsync(x => x.Id == id);
id++;
return id;
}
then it will be:
public async Task<int> Get(int id)
{
int value = 0;
void perform()
{
switch (value)
{
case 0:
id = 0;
value++;
perform();
break;
case 1:
//I do not sure
db.Values.Get(x => x.Id == id).ContinueWith(() =>
{
value++;
perform();
});
// I do not sure if it will be this code:
ThreadPool.QueueUserWorkItem((obj) =>
{
db.Values.Get(x => x.Id == id).ContinueWith(() =>
{
value++;
perform();
});
});
break;
case 2:
id++;
break;
}
}
perform();
return id;
}
if each request comes the runtime use new thread I think not use async is same to use.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder if the runtime will use new thread when a request comes. if so I think there is no difference between
useornot useasync.if there is function :
then it will be:
if each request comes the runtime use new thread I think not use async is same to use.
Beta Was this translation helpful? Give feedback.
All reactions