I
I
iXelper2018-10-12 15:49:03
C++ / C#
iXelper, 2018-10-12 15:49:03

Asynchronous programming how?

There is a function for example:

public void outTextToConsole(){
Console.WriteLine("Привет мир !");
}

How to call it asynchronously?
How many did not look at the documentation I can not understand ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dasha Tsiklauri, 2018-10-12
@iXelper

Task.Run(()=>outTextToConsole())
if you need to wait for the completion of the task, then add await, you get await Task.Run,
but this is the creation of a thread on the CPU, all methods that have the nature of working with a disk, network, etc. that can return a result on interruption, as a rule, they already return a result of type Task and have an Async suffix

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question