Interface where one of the implementations needs to be async

Viewed 1075

I have an interface, which delivers me a certain path. In one of my implementations I need to use async, but I haven't figured out how to get the result of an async method into a synchronous method. Here is the code sample:

Interface:

public interface IFilePath
{
    string GetAsset();
}

Problematic implementation:

public class FilePath : IFilePath
{
    public string GetAsset()
    {
        return GetAssetAssync();
    }

    private async Task<string> GetAssetAssync()
    {
        StorageFolder assetsFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets").AsTask().ConfigureAwait(false);
        return assetsFolder.Path;
    }
}

Only for this implementation I need the async call. All others do not need it. So I can't use public Task<string> GetAsset() or can I somehow?

1 Answers
Related