Skip to content

Commit 8bd15b1

Browse files
doc(async): some comments on async I/O
1 parent 0568981 commit 8bd15b1

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ More information, including the Class Reference, is on the [Project](https://ric
1414
## Features
1515

1616
- Targets .NET Framework 4.5, .NET Standard 1.4 and .NET Standard 2.0
17-
- Asynchronous I/O to an IPFS server
17+
- [Asynchronous I/O](https://richardschneider.github.io/net-ipfs-api/articles/async.html) to an IPFS server
1818
- Supports [cancellation](https://richardschneider.github.io/net-ipfs-api/articles/cancellation.html) of all requests to the IPFS Server
1919
- C# style access to the [ipfs core interface](https://github.com/ipfs/interface-ipfs-core#api)
2020
- [Block API](https://richardschneider.github.io/net-ipfs-api/api/Ipfs.Api.BlockApi.html)

doc/Documentation.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<Content Include="template\fonts\Lato-Regular.woff" />
9090
<Content Include="template\fonts\Lato-Regular.woff2" />
9191
<Content Include="articles\cancellation.md" />
92+
<Content Include="articles\async.md" />
9293
<None Include="Web.Debug.config">
9394
<DependentUpon>Web.config</DependentUpon>
9495
</None>

doc/articles/async.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Asynchronous I/O
2+
3+
All requests to the IPFS server are [asynchronous](https://docs.microsoft.com/en-us/dotnet/csharp/async),
4+
which does not block current thread.
5+
6+
This means that callers should **normally** use the `async/await` paradigm
7+
8+
```cs
9+
async Task<string> AddText()
10+
{
11+
var result = await ipfs.FileSystem.AddTextAsync("I am pinned");
12+
return result.Hash;
13+
}
14+
```
15+
16+
If you need to perform a synchronous operation, then this can work
17+
18+
```cs
19+
string AddText()
20+
{
21+
var result = ipfs.FileSystem.AddTextAsync("I am pinned").Result;
22+
return result.Hash;
23+
}
24+
```

doc/articles/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
href: intro.md
33
- name: Cancellation
44
href: cancellation.md
5+
- name: Asynchronous I/O
6+
href: async.md

0 commit comments

Comments
 (0)