[英]C# does not contain a definition for 'GetAwaiter' and the best extension method overload requires a receiver of type 'Task'
I am trying to make a GTA 5 Cheat I have the injector done and am working on the UI.我正在尝试制作 GTA 5 Cheat 我已经完成了注射器并正在处理 UI。 I have tried to delete await taskAwaiter;
我试图删除 await taskAwaiter; from my code and it would not launch at that point My code:
从我的代码中,它不会在那时启动我的代码:
TaskAwaiter<string> taskAwaiter = (await MainWindow.client.PostAsync("https://pastebin.com/Mypaste", new FormUrlEncodedContent(nameValueCollection))).Content.ReadAsStringAsync().GetAwaiter();
if (!taskAwaiter.IsCompleted)
{
await taskAwaiter;
TaskAwaiter<string> taskAwaiter2;
taskAwaiter = taskAwaiter2;
taskAwaiter2 = default(TaskAwaiter<string>);
}
if (taskAwaiter.GetResult() != "success")
{
this.UpdateStatus("Auth failed");
this.TimeoutReset();
this.cant_click = false;
}
else
{
this.UpdateStatus("Logged in");
File.WriteAllText(this.auth_file, this.user.ToString());
this.Download();
}
The await
operator isn't meant to be used with an awaiter - it calls GetAwaiter
itself (if necessary). await
运算符不打算与 awaiter 一起使用 - 它会调用GetAwaiter
本身(如有必要)。
It's not really clear what you're trying to achieve here, and this looks like half-decompiled code, but I suspect you just want something like:目前还不清楚你在这里想要实现什么,这看起来像是半反编译的代码,但我怀疑你只是想要这样的东西:
using (var response = await MainWindow.client.PostAsync("https://pastebin.com/Mypaste", new FormUrlEncodedContent(nameValueCollection)))
{
var text = await response.Content.ReadAsStringAsync();
if (text == "Success")
{
UpdateStatus("Logged in");
File.WriteAllText(auth_file, user.ToString());
Download();
}
else
{
UpdateStatus("Auth failed");
TimeoutReset();
cant_click = false;
}
}
In each case with this code, the await
operator is used on a task , not on an awaiter .在此代码的每种情况下,
await
运算符都用于task ,而不是awaiter 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.