Added SteamClient.OnCallbackException

This commit is contained in:
Garry Newman 2019-05-03 14:11:05 +01:00
parent 4ed8a4250b
commit 5fdbf02b29
2 changed files with 18 additions and 9 deletions

View File

@ -14,6 +14,13 @@ namespace Steamworks
[AssemblyInitialize]
public static void AssemblyInit( TestContext context )
{
Steamworks.SteamClient.OnCallbackException = ( e ) =>
{
Console.Error.WriteLine( e.Message );
Console.Error.WriteLine( e.StackTrace );
Assert.Fail( e.Message );
};
//
// Init Client
//

View File

@ -48,6 +48,8 @@ namespace Steamworks
RunCallbacksAsync();
}
public static Action<Exception> OnCallbackException;
public static bool IsValid => initialized;
internal static async void RunCallbacksAsync()
@ -55,14 +57,7 @@ namespace Steamworks
while ( IsValid )
{
await Task.Delay( 16 );
try
{
SteamAPI.RunCallbacks();
}
catch ( System.Exception )
{
// TODO - error outputs
}
RunCallbacks();
}
}
@ -97,9 +92,16 @@ namespace Steamworks
}
public static void RunCallbacks()
{
try
{
SteamAPI.RunCallbacks();
}
catch ( System.Exception e )
{
OnCallbackException?.Invoke( e );
}
}
internal static void UnregisterCallback( IntPtr intPtr )
{