forked from microsoft/psi-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (35 loc) · 1.11 KB
/
Program.cs
File metadata and controls
42 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
namespace HelloWorld
{
using System;
using Microsoft.Psi;
/// <summary>
/// Hello world sample.
/// </summary>
public static class Program
{
/// <summary>
/// Main entry point.
/// </summary>
public static void Main()
{
// Create a pipeline
var p = Pipeline.Create();
// Create a timer component that produces a message every second
var timer = Timers.Timer(p, TimeSpan.FromSeconds(1));
// For each message created by the timer, print "Hello world!"
// along with the message's originating time.
timer.Do((t, e) =>
{
Console.WriteLine($"{e.OriginatingTime}: Hello world!");
});
// Run the pipeline, but don't block here
p.RunAsync();
// Wait for the user to hit a key before closing the pipeline
Console.ReadKey();
// Close the pipeline
p.Dispose();
}
}
}