public class DataStorage
{
    public async Task WriteFile(string key, object value)
    {
        try 
        {
            var jsonValue = JsonConvert.SerializeObject(value);
            using (var file = await folder.OpenStreamForWriteAsync(key, CreationCollisionOption.ReplaceExisting))
            using (var stream = new StreamWriter(file))
                await stream.WriteAsync(jsonValue);
        }
        catch (Exception exception)
        {
            AsyncErrorHandler.HandleException(exception);
        } 
    }
}

 

public static class AsyncErrorHandler
{
    public static void HandleException(Exception exception)
    {
        Debug.WriteLine(exception);
    }
}

 https://github.com/Fody/AsyncErrorHandler/blob/master/README.md

相关文章:

  • 2021-04-05
  • 2021-06-12
  • 2021-11-13
  • 2021-10-31
  • 2022-01-22
  • 2022-02-01
  • 2021-09-04
猜你喜欢
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
相关资源
相似解决方案