2
Usually, on . NET, I run things time-consuming asynchronously so as not to stop the thread visual. In a simple example, if I have a loading in the UI, should lengthy things be executed without awaited, they lock that loading, who was executed in the thread visual.
Actions that may be time-consuming, such as processing a list, loops or read files, I run asynchronously. But when I have things I know are not time-consuming, like a simple conditional structure:
public bool? ToBoolean(int input)
{
if (input == 1)
{
return true;
}
else if (input == 0)
{
return false;
}
return null;
}
For these cases, which I know are fast (in theory), I should have something like?
public async Task<bool?> ToBooleanAsync(int input)
{
return await Task.Run(() => ToBoolean(input));
}
I must perform things quickly asynchronously, and why (or why not)?
How do I mount such a structure? Can I create another question
– vinibrsl
You don’t assemble, this is internal, the compiler generates a part, the libraries do another.
– Maniero