Error: FireSharp's SetAsync and GetAsync not marked as async?

Error: FireSharp's SetAsync and GetAsync not marked as async?

我是初学者,最近尝试开始使用 FireSharp,甚至传输了一些数据:

This was my first Code to send data to the server:

public static class Client
{
   static IFirebaseClient client;

   static IFirebaseConfig config = new FirebaseConfig
   {
       AuthSecret = "MyAuthSecret",
       BasePath = "MyBasePath"
   };


   public static bool Start()
   {
       client = new FirebaseClient(config);

       if (client != null) 
       {
           return true; 
       } else {
           return false;
       }
   }

   public static void Send(Data data)
   {
       SetResponse response = await client.SetAsync("Testpath", data);
   }

但是在第 SetResponse response = await client.SetAsync("Testpath", data); 行,我收到以下错误消息:
The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.

我仍然能够发送数据,只需将线路减少到 client.SetAsync("Testpath", data);。我知道这不理想,因为我没有得到那样的回应,但它奏效了!

真正的问题是,我没有设法为 FirebaseResponse response = await client.GetAsync("Testpath"); 想出这样的解决方法。这样我目前无法从服务器获取数据。

有人知道问题出在哪里或如何解决吗?

My ideas were:

  • Maybe it has something to do with the fact that I put all this in a static class.
  • Maybe the FireSharp Libary is broken in the current version.
  • Maybe I could manually mark the methods as async, since thats whats the error-message saying.
  • Or I could manually change it's return type, as the error-message says.
  • Maybe I understood the whole "await" and "async" thing wrong.
  • The manual says, "FirebaseClient uses Newtonsoft.Json by default. Maybe that could have anything to do with it.

但我还没有尝试过它们中的任何一个,因为我不知道如何。我不知道更改库的代码是否可能并且是否有意义,或者 "change the return type" 的错误消息意味着什么。我看了一个教程并查看了 manual,但找不到有关此问题的任何信息。

非常感谢任何帮助,因为到目前为止我无法在 Internet 上找到有关此问题的任何信息。

您的发送方法必须是async

public static async Task Send(Data data)