|
|
|
@ -130,21 +130,34 @@ namespace Avalonia.Win32 |
|
|
|
|
|
|
|
public void ProcessMessage() |
|
|
|
{ |
|
|
|
UnmanagedMethods.MSG msg; |
|
|
|
UnmanagedMethods.GetMessage(out msg, IntPtr.Zero, 0, 0); |
|
|
|
UnmanagedMethods.TranslateMessage(ref msg); |
|
|
|
UnmanagedMethods.DispatchMessage(ref msg); |
|
|
|
|
|
|
|
if (UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0) > -1) |
|
|
|
{ |
|
|
|
UnmanagedMethods.TranslateMessage(ref msg); |
|
|
|
UnmanagedMethods.DispatchMessage(ref msg); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) |
|
|
|
?.Log(this, "Unmanaged error in {0}. Error Code: {1}", nameof(ProcessMessage), Marshal.GetLastWin32Error()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void RunLoop(CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
while (!cancellationToken.IsCancellationRequested) |
|
|
|
var result = 0; |
|
|
|
while (!cancellationToken.IsCancellationRequested |
|
|
|
&& (result = UnmanagedMethods.GetMessage(out var msg, IntPtr.Zero, 0, 0)) > 0) |
|
|
|
{ |
|
|
|
UnmanagedMethods.MSG msg; |
|
|
|
UnmanagedMethods.GetMessage(out msg, IntPtr.Zero, 0, 0); |
|
|
|
UnmanagedMethods.TranslateMessage(ref msg); |
|
|
|
UnmanagedMethods.DispatchMessage(ref msg); |
|
|
|
} |
|
|
|
if (result < 0) |
|
|
|
{ |
|
|
|
Logging.Logger.TryGet(Logging.LogEventLevel.Error, Logging.LogArea.Win32Platform) |
|
|
|
?.Log(this, "Unmanaged error in {0}. Error Code: {1}", nameof(RunLoop), Marshal.GetLastWin32Error()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action callback) |
|
|
|
|