我最近尝试使用OpenTL快速入门页上的自动更新示例,仅使用以下基本示例
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;
}
};
它不会编译抛出此错误:Error CS0079 The event 'IUpdatesService.AutoReceiveUpdates' can only appear to the left of += or -=
我将其放入异步Task函数中,但我认为这不是问题。我真的不知道如何使用这样的异步事件。
link to the example
最佳答案
您写的方式是错误的。它应该是
clientApi.UpdatesService.AutoReceiveUpdates += async update =>
{
// Handle updates
switch (update)
{
关于c# - 电报消息的OpenTl自动更新引发错误CS0079 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64806756/