forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
36 lines (31 loc) · 1.4 KB
/
Program.cs
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
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
using nanoFramework.Runtime.Events;
using System;
using System.Diagnostics;
using System.Threading;
namespace NativeEvents
{
public class Program
{
public static void Main()
{
// setup event handler for custom event
CustomEvent.CustomEventPosted += CustomEventHandler;
/////////////////////////////////////////////////////////////////////////////////////////
// VERY VERY VERY IMPORTANT //
// The above WON'T produce any effect unless you have a call in native code like this: //
// //
// PostManagedEvent( EVENT_CUSTOM, 0, 1111, 2222 ); //
// //
/////////////////////////////////////////////////////////////////////////////////////////
Thread.Sleep(Timeout.Infinite);
}
private static void CustomEventHandler(object sender, CustomEventArgs e)
{
Debug.WriteLine($"Custom event received. Data1: { e.Data1 } Data2: { e.Data2 }.");
}
}
}