Compare commits
2
Commits
29d179a23a
...
dev/async
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
980e8c4e04 | ||
|
|
1b5bf4f8d4 |
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
long startTime = Stopwatch.GetTimestamp();
|
||||
|
||||
Console.WriteLine(
|
||||
$"[Program] start - thread {Environment.CurrentManagedThreadId}, t = {Stopwatch.GetElapsedTime(startTime).TotalMilliseconds} ms"
|
||||
);
|
||||
|
||||
var task = FetchUserAsync(42);
|
||||
Console.WriteLine(
|
||||
$"[Program] after fetch - thread {Environment.CurrentManagedThreadId}, t = {Stopwatch.GetElapsedTime(startTime).TotalMilliseconds} ms"
|
||||
);
|
||||
|
||||
var user = await task;
|
||||
Console.WriteLine(
|
||||
$"[Program] after await - thread {Environment.CurrentManagedThreadId}, t = {Stopwatch.GetElapsedTime(startTime).TotalMilliseconds} ms"
|
||||
);
|
||||
|
||||
return;
|
||||
|
||||
async Task<string> FetchUserAsync(int id)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[FetchUserAsync] entered - thread {Environment.CurrentManagedThreadId}, t = {Stopwatch.GetElapsedTime(startTime).TotalMilliseconds} ms"
|
||||
);
|
||||
await Task.Delay(500);
|
||||
Console.WriteLine(
|
||||
$"[FetchUserAsync] resumed, thread {Environment.CurrentManagedThreadId}, t = {Stopwatch.GetElapsedTime(startTime).TotalMilliseconds} ms"
|
||||
);
|
||||
|
||||
return $"User ID: {id}";
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>async_lab</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 113 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user