-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageLoop.cs
31 lines (26 loc) · 907 Bytes
/
MessageLoop.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
using Ascpixi.Wakatime.FLStudio.Native;
using Ascpixi.Wakatime.FLStudio.Native.Enumerations;
namespace Ascpixi.Wakatime.FLStudio;
public static class MessageLoop
{
/// <summary>
/// Creates a new message loop thread.
/// </summary>
public static void Spawn() => new Thread(Run).Start();
/// <summary>
/// Runs the message loop in the calling thread. This method will only return
/// once a WM_QUIT message is received.
/// </summary>
public static void Run()
{
Log.Info("Message loop started.");
while (User32.GetMessage(out var msg, default, 0, 0)) {
if (msg.Message == WindowMessageKind.WM_QUIT) {
Log.Info("WM_QUIT received - terminating message loop.");
break;
}
User32.TranslateMessage(ref msg);
User32.DispatchMessage(ref msg);
}
}
}