Apps.GetFileDetails propert async working example

This commit is contained in:
Garry Newman 2019-04-13 18:47:23 +01:00
parent fac123324d
commit 429d1937f9

View File

@ -177,7 +177,7 @@ public static string AppInstallDir( AppId appid )
public static SteamId AppOwner => steamapps.GetAppOwner().Value; public static SteamId AppOwner => steamapps.GetAppOwner().Value;
/// <summary> /// <summary>
/// Gets the associated launch parameter if the game is run via steam://run/<appid>/?param1=value1;param2=value2;param3=value3 etc. /// Gets the associated launch parameter if the game is run via steam://run/appid/?param1=value1;param2=value2;param3=value3 etc.
/// Parameter names starting with the character '@' are reserved for internal use and will always return an empty string. /// Parameter names starting with the character '@' are reserved for internal use and will always return an empty string.
/// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, /// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game,
/// but it is advised that you not param names beginning with an underscore for your own features. /// but it is advised that you not param names beginning with an underscore for your own features.
@ -213,13 +213,19 @@ public static async Task<FileDetails> GetFileDetails( string filename )
{ {
var call = steamapps.GetFileDetails( filename ); var call = steamapps.GetFileDetails( filename );
while ( !Utils.IsCallComplete( call, out bool failed ) ) while ( !call.IsComplete() )
{ {
await Task.Delay( 1 ); await Task.Delay( 1 );
} }
var r = call.GetResult();
if ( !r.HasValue )
throw new System.Exception( "Something went wrong" );
return new FileDetails(); return new FileDetails
{
SizeInBytes = r.Value.FileSize
};
} }
} }