diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index be83d68..79d1d17 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -41,7 +41,10 @@ public static void Init( uint appid ) SteamNetworkingSockets.InstallEvents(); SteamInput.InstallEvents(); - RunCallbacksAsync(); + if ( asyncCallbacks ) + { + RunCallbacksAsync(); + } } static List openIterfaces = new List(); @@ -73,7 +76,15 @@ internal static async void RunCallbacksAsync() while ( IsValid ) { await Task.Delay( 16 ); - RunCallbacks(); + + try + { + RunCallbacks(); + } + catch ( System.Exception e ) + { + OnCallbackException?.Invoke( e ); + } } } @@ -123,14 +134,7 @@ public static void RunCallbacks() { if ( !IsValid ) return; - try - { - SteamAPI.RunCallbacks(); - } - catch ( System.Exception e ) - { - OnCallbackException?.Invoke( e ); - } + SteamAPI.RunCallbacks(); } internal static void UnregisterCallback( IntPtr intPtr ) diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index dd8e6db..818d60b 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -104,7 +104,10 @@ public static void Init( AppId appid, SteamServerInit init ) InstallEvents(); - RunCallbacksAsync(); + if ( asyncCallbacks ) + { + RunCallbacksAsync(); + } } static List openIterfaces = new List(); @@ -147,7 +150,15 @@ internal static async void RunCallbacksAsync() { while ( IsValid ) { - RunCallbacks(); + try + { + RunCallbacks(); + } + catch ( System.Exception e ) + { + OnCallbackException?.Invoke( e ); + } + await Task.Delay( 16 ); } } @@ -157,14 +168,7 @@ internal static async void RunCallbacksAsync() /// public static void RunCallbacks() { - try - { - SteamGameServer.RunCallbacks(); - } - catch ( System.Exception e ) - { - OnCallbackException?.Invoke( e ); - } + SteamGameServer.RunCallbacks(); } ///