mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Internal interfaces do the await callback automatically
This commit is contained in:
parent
cce25e6f77
commit
d9da40c0e8
@ -16,13 +16,23 @@ public SteamApiCallback( ulong callbackHandle )
|
||||
CallHandle = callbackHandle;
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
public bool IsComplete( out bool failed )
|
||||
{
|
||||
return Utils.IsCallComplete( CallHandle, out bool failed );
|
||||
return Utils.IsCallComplete( CallHandle, out failed );
|
||||
}
|
||||
|
||||
public T? GetResult()
|
||||
public async Task<T?> GetResult()
|
||||
{
|
||||
bool failed = false;
|
||||
|
||||
while ( !IsComplete( out failed ) )
|
||||
{
|
||||
await Task.Delay( 1 );
|
||||
}
|
||||
|
||||
if ( failed )
|
||||
return null;
|
||||
|
||||
return Utils.GetResult<T>( CallHandle );
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SteamNative;
|
||||
|
||||
|
||||
@ -337,9 +338,9 @@ public void RequestAllProofOfPurchaseKeys()
|
||||
private GetFileDetailsDelegate GetFileDetailsDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public SteamApiCallback<FileDetailsResult_t> GetFileDetails( string pszFileName )
|
||||
public async Task<FileDetailsResult_t?> GetFileDetails( string pszFileName )
|
||||
{
|
||||
return new SteamApiCallback<FileDetailsResult_t>( GetFileDetailsDelegatePointer( Self, pszFileName ) );
|
||||
return await (new SteamApiCallback<FileDetailsResult_t>( GetFileDetailsDelegatePointer( Self, pszFileName ) )).GetResult();
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SteamNative;
|
||||
|
||||
|
||||
@ -266,9 +267,9 @@ public bool BOverlayNeedsPresent()
|
||||
private CheckFileSignatureDelegate CheckFileSignatureDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public SteamApiCallback<CheckFileSignature_t> CheckFileSignature( string szFileName )
|
||||
public async Task<CheckFileSignature_t?> CheckFileSignature( string szFileName )
|
||||
{
|
||||
return new SteamApiCallback<CheckFileSignature_t>( CheckFileSignatureDelegatePointer( Self, szFileName ) );
|
||||
return await (new SteamApiCallback<CheckFileSignature_t>( CheckFileSignatureDelegatePointer( Self, szFileName ) )).GetResult();
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
|
@ -17,6 +17,7 @@ public void GenerateVTableClass( string className, string filename )
|
||||
WriteLine( $"using System;" );
|
||||
WriteLine( $"using System.Runtime.InteropServices;" );
|
||||
WriteLine( $"using System.Text;" );
|
||||
WriteLine( $"using System.Threading.Tasks;" );
|
||||
WriteLine( $"using SteamNative;" );
|
||||
WriteLine();
|
||||
|
||||
|
@ -73,8 +73,8 @@ internal class SteamApiCallType : BaseType
|
||||
{
|
||||
public string CallResult;
|
||||
public override string TypeName => "SteamAPICall_t";
|
||||
public override string Return( string varname ) => $"return new SteamApiCallback<{CallResult}>( {varname} );";
|
||||
public override string ReturnType => $"SteamApiCallback<{CallResult}>";
|
||||
public override string Return( string varname ) => $"return await (new SteamApiCallback<{CallResult}>( {varname} )).GetResult();";
|
||||
public override string ReturnType => $"async Task<{CallResult}?>";
|
||||
}
|
||||
|
||||
internal class CSteamIdType : BaseType
|
||||
|
Loading…
Reference in New Issue
Block a user