Added Dispatch.OnException

This commit is contained in:
Garry Newman 2020-02-28 12:10:53 +00:00
parent c24b247094
commit b265084d18
3 changed files with 14 additions and 2 deletions

View File

@ -22,7 +22,7 @@ public static void AssemblyInit( TestContext context )
Console.WriteLine( $"" );
};
Steamworks.SteamClient.OnCallbackException = ( e ) =>
Steamworks.Dispatch.OnException = ( e ) =>
{
Console.Error.WriteLine( e.Message );
Console.Error.WriteLine( e.StackTrace );

View File

@ -103,7 +103,7 @@ public async Task NormalEndtoEnd()
}
[TestMethod]
public async Task NetAddressTest()
public void NetAddressTest()
{
{
var n = NetAddress.From( "127.0.0.1", 12445 );

View File

@ -27,6 +27,14 @@ public static class Dispatch
/// </summary>
public static Action<CallbackType, string, bool> OnDebugCallback;
/// <summary>
/// Called if an exception happens during a callback/callresult.
/// This is needed because the exception isn't always accessible when running
/// async.. and can fail silently. With this hooked you won't be stuck wondering
/// what happened.
/// </summary>
public static Action<Exception> OnException;
#region interop
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ManualDispatch_Init", CallingConvention = CallingConvention.Cdecl )]
internal static extern void SteamAPI_ManualDispatch_Init();
@ -99,6 +107,10 @@ internal static void Frame( HSteamPipe pipe )
}
}
}
catch ( System.Exception e )
{
OnException?.Invoke( e );
}
finally
{
runningFrame = false;