簡體   English   中英

OpenTl 自動更新電報消息會引發錯誤 CS0079 c#

[英]OpenTl auto update on telegram messages throws error CS0079 c#

我最近嘗試使用 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;
    }
};

它不會編譯拋出此錯誤:

錯誤 CS0079 事件“IUpdatesService.AutoReceiveUpdates”只能出現在 += 或 -= 的左側

我把它放到一個異步任務函數中,但我認為這不是問題所在。 我真的不知道如何使用這樣的異步事件。 鏈接到示例

你寫的方式不對。 而是應該

clientApi.UpdatesService.AutoReceiveUpdates += async update => 
{
// Handle updates
 switch (update)
    {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM