OpenTl自动更新电报消息引发错误CS0079 c#
我最近尝试使用OpenTL快速入门页面上的自动更新示例,并仅使用以下基本示例OpenTl自动更新电报消息引发错误CS0079 c#,c#,error-handling,compiler-errors,C#,Error Handling,Compiler Errors,我最近尝试使用OpenTL快速入门页面上的自动更新示例,并仅使用以下基本示例 await clientApi.UpdatesService.AutoReceiveUpdates += update => { // Handle updates switch (update) { case TUpdates updates: break; case TUpdatesCombined updatesCombined:
await clientApi.UpdatesService.AutoReceiveUpdates += update =>
{
// Handle updates
switch (update)
{
case TUpdates updates:
break;
case TUpdatesCombined updatesCombined:
break;
case TUpdateShort updateShort:
break;
case TUpdateShortChatMessage updateShortChatMessage:
break;
case TUpdateShortMessage updateShortMessage:
break;
case TUpdateShortSentMessage updateShortSentMessage:
break;
case TUpdatesTooLong updatesTooLong:
break;
}
};
如果抛出以下错误,则不会编译:
错误CS0079事件“IUpdatesService.AutoReceiveUpdates”只能出现在+=或的左侧-=
我把它放到了一个异步任务函数中,但我认为这不是问题所在。我真的不知道如何使用这样的异步事件。
你写这篇文章的方式是错误的。应该是这样的
clientApi.UpdatesService.AutoReceiveUpdates += async update =>
{
// Handle updates
switch (update)
{
谢谢,但是现在它给出了一个警告,它没有使用'await',并且将同步执行,我应该把await放在哪里?