Skip to content

Commit b3d2cab

Browse files
committed
Update README.md
1 parent 81e732c commit b3d2cab

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

README.md

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,35 @@ private:
214214
startup_(example::main);
215215
```
216216
217+
**or simply**
218+
219+
```cpp
220+
#include <xtd/xtd>
221+
222+
auto get_message() -> task<string> {
223+
co_return "Hello, World!";
224+
}
225+
226+
auto get_size(auto message) -> task<size> {
227+
co_return message.length();
228+
}
229+
230+
auto main_async() -> task<> {
231+
println("[main], thread {}] -> start", thread::current_thread().managed_thread_id());
232+
233+
auto message = co_await get_message();
234+
auto length = co_await get_size(message);
235+
236+
println("message : {}", message);
237+
println("length : {}", length);
238+
println("[main, thread {}] -> end", thread::current_thread().managed_thread_id());
239+
}
240+
241+
auto main() -> int {
242+
main_async().wait();
243+
}
244+
```
245+
217246
#### CMakeLists.txt
218247

219248
```cmake
@@ -225,6 +254,23 @@ add_sources(hello_world_coroutine.cpp)
225254
target_type(CONSOLE_APPLICATION)
226255
```
227256

257+
#### Build and run
258+
259+
Open "Command Prompt" or "Terminal". Navigate to the folder that contains the project and type the following:
260+
261+
```shell
262+
xtdc run
263+
```
264+
265+
#### Output
266+
267+
```
268+
[main], thread 1] -> start
269+
message : Hello, World!
270+
length : 13
271+
[main, thread 3] -> end
272+
```
273+
228274
### Forms (GUI like WinForms)
229275

230276
#### hello_world_forms.cpp
@@ -388,23 +434,6 @@ xtdc run
388434

389435
![Screenshot](https://github.com/gammasoft71/xtd/blob/master/docs/pictures/examples/hello_world_tunit_vs.png)
390436

391-
#### Build and run
392-
393-
Open "Command Prompt" or "Terminal". Navigate to the folder that contains the project and type the following:
394-
395-
```shell
396-
xtdc run
397-
```
398-
399-
#### Output
400-
401-
```
402-
[main], thread 1] -> start
403-
message : Hello, World!
404-
length : 13
405-
[main, thread 3] -> end
406-
```
407-
408437
## Gallery
409438

410439
### Minesweeper

0 commit comments

Comments
 (0)