久久久久久久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 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 美女在线一区二区 | 国产91丝袜在线熟 | 亚洲精视频| 国产色片| 国产精品欧美大片 | 亚洲免费成人 | 黄色一级电影在线观看 | 久久综合久色欧美综合狠狠 | 国产成人网 | 午夜免费看| 精品国产乱码一区二区三区 | 国产黄色大片在线观看 | 男人久久天堂 | 亚洲 成人 av | 一区二区三区在线看 | 欧美日韩福利视频 | 成人免费观看男女羞羞视频 | 日韩精品一区二区三区视频播放 | 成人一区二区三区在线观看 | 一区二区三区四区在线视频 | 久久久久久久av | 久久国内| 精品久久九九 | 在线免费观看黄色 | 久久久久国产精品 | 人人玩人人添人人澡欧美 | 亚洲视频一区在线 | 成人精品国产免费网站 | 日韩视频1 | 国产精品亚洲视频 | 日韩成人免费视频 | 亚洲人人 | 日本在线免费视频 | 亚洲一区国产 | 一区二区三区免费 | 亚州精品天堂中文字幕 | 国产一级视频 | 日韩国产一区二区三区 | 国产一区二区三区www | 99精品久久 | 亚洲永久字幕 |