Move try catch, because i had issues with it throwing when doing the tick - oops
This commit is contained in:
parent
f0a5a48c73
commit
0d056215bc
@ -137,13 +137,12 @@ public class DialAction : EncoderBase
|
||||
public override void DialUp(DialPayload payload)
|
||||
{
|
||||
//dial unpressed
|
||||
Logger.Instance.LogMessage(TracingLevel.INFO, "Dial Up");
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.DEBUG, "Disposing");
|
||||
if(_foregroundWindowChangedEvent != IntPtr.Zero)
|
||||
if (_foregroundWindowChangedEvent != IntPtr.Zero)
|
||||
{
|
||||
Native.UnhookWinEvent(_foregroundWindowChangedEvent);
|
||||
}
|
||||
@ -151,17 +150,24 @@ public class DialAction : EncoderBase
|
||||
}
|
||||
|
||||
public override async void OnTick()
|
||||
{
|
||||
try
|
||||
{
|
||||
//called once every 1000ms and can be used for updating the title/image of the key
|
||||
var activeSession = _audioHelper.GetActiveSession(settings.FallbackBehavior);
|
||||
|
||||
if(activeSession != null)
|
||||
if (activeSession != null)
|
||||
{
|
||||
_currentAudioSession = activeSession;
|
||||
}
|
||||
|
||||
await UpdateStateIfNeeded();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.ERROR, $"Exception on WinEventProc\n {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateStateIfNeeded()
|
||||
{
|
||||
@ -170,7 +176,7 @@ public class DialAction : EncoderBase
|
||||
|
||||
var uiState = new UIState(_currentAudioSession);
|
||||
|
||||
if ( _previousState != null && uiState != null &&
|
||||
if (_previousState != null && uiState != null &&
|
||||
uiState.Title == _previousState.Title &&
|
||||
uiState.Value.Value == _previousState.Value.Value &&
|
||||
uiState.Value.Opacity == _previousState.Value.Opacity &&
|
||||
@ -207,16 +213,8 @@ public class DialAction : EncoderBase
|
||||
|
||||
|
||||
public void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnTick();
|
||||
Thread.Sleep(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Instance.LogMessage(TracingLevel.ERROR, $"Exception on WinEventProc\n {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user