mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-15 16:19:00 +03:00
41 lines
790 B
C#
41 lines
790 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Steamworks
|
|
{
|
|
/// <summary>
|
|
/// Results are Steam Callbacks that are direct responses to function calls
|
|
/// </summary>
|
|
public struct Result<T> where T : struct, ISteamCallback
|
|
{
|
|
public ulong CallHandle;
|
|
|
|
public Result( ulong callbackHandle )
|
|
{
|
|
CallHandle = callbackHandle;
|
|
}
|
|
|
|
public bool IsComplete( out bool failed )
|
|
{
|
|
return SteamUtils.IsCallComplete( CallHandle, out failed );
|
|
}
|
|
|
|
public async Task<T?> GetResult()
|
|
{
|
|
bool failed = false;
|
|
|
|
while ( !IsComplete( out failed ) )
|
|
{
|
|
await Task.Delay( 1 );
|
|
}
|
|
|
|
if ( failed )
|
|
return null;
|
|
|
|
return SteamUtils.GetResult<T>( CallHandle );
|
|
}
|
|
}
|
|
} |