You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
727 B
29 lines
727 B
2 years ago
|
using System;
|
||
|
using System.Diagnostics;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace Samples
|
||
|
{
|
||
|
class MessagePrinterSample
|
||
|
{
|
||
|
private delegate Task MessagePrinter(string message);
|
||
|
|
||
|
private static async Task PrintMessageAsync(string message)
|
||
|
{
|
||
|
await Task.Delay(1000);
|
||
|
Console.WriteLine(message);
|
||
|
}
|
||
|
|
||
|
public static void Sample()
|
||
|
{
|
||
|
MessagePrinter printer = PrintMessageAsync;
|
||
|
Console.WriteLine("Start...");
|
||
|
|
||
|
printer("This is first message");
|
||
|
printer("This is second message");
|
||
|
printer("This is third message");
|
||
|
|
||
|
Console.WriteLine("Finish...");
|
||
|
}
|
||
|
}
|
||
|
}
|