久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

跨線程操作在 Windows 窗體中無效

Cross-thread operation not valid in Windows Forms(跨線程操作在 Windows 窗體中無效)
本文介紹了跨線程操作在 Windows 窗體中無效的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

誰能幫助我我有一個問題我試圖通過線程池讓這段代碼在后臺工作,但我似乎無法讓它工作我一直收到這個錯誤:

Could anyone help me i have a problem I'm trying to get this code to work in the background via threadpool but i cannot seem to get it to work i keep getting this error:

Cross-thread operation not valid: Control 'ListBox3' accessed
from a thread other than the thread it was created on. 

這是我正在使用的代碼:

Here is the code i am using:

private void DoWork(object o)
{
    var list = ListBox3;

    var request = createRequest(TxtServer.Text, WebRequestMethods.Ftp.ListDirectory);

    using (var response = (FtpWebResponse)request.GetResponse())
    {
        using (var stream = response.GetResponseStream())
        {
            using (var reader = new StreamReader(stream, true))
            {
                while (!reader.EndOfStream)
                {
                    list.Items.Add(reader.ReadLine());
                    ResultLabel.Text = "Connected";
                }
            }
        }
    }
}

推薦答案

您需要調用委托來更新列表.請參閱此 MSDN 示例.

You need to invoke a delegate to update the list. See this MSDN example.

這篇關于跨線程操作在 Windows 窗體中無效的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 久久久久久久久久国产精品 | 日韩精品一级毛片在线播放 | 欧美成人免费在线视频 | 爱爱免费小视频 | 欧美日韩在线视频观看 | 性久久久久久 | 天天干天天操天天爽 | 国产精品主播一区二区 | 久久夜色精品国产欧美乱极品 | 黄色免费一级片 | 国产激情网站 | 日韩精品在线免费观看 | 99在线视频免费观看 | 黄色一级网站 | 久草资源网 | 日日干日日 | 久久精品一区二区三区四区 | 色www| 国产黄色免费看 | 可以在线观看的av | 亚洲精品一二 | 免费看a级片| 亚洲综合在线视频 | 日本视频免费观看 | 色哟哟一区二区 | 日本一区二区不卡视频 | 黑人巨大精品欧美一区二区 | 欧美精品999| 久久黄视频 | 久久久久久久久国产 | 看毛片视频 | 91久久国产综合久久91精品网站 | 欧美性猛交乱大交 | 青青草福利视频 | 国产精品一区二区不卡 | 日本不卡在线 | 精品久久网站 | 日本少妇高潮达到高潮 | 亚洲精品资源 | 成人a毛片 | 欧美激情第二页 |