gpt4 book ai didi

c# - 如何在bho中的异步httpwebrequest回调中访问ui线程

转载 作者:行者123 更新时间:2023-12-03 13:21:51 27 4
gpt4 key购买 nike

我正在努力访问浏览器帮助程序对象中异步httpwebrequest回调中的ui线程。当前的文档和窗口无法反射(reflect)调用线程中见证的内容,因此我无法根据需要更新UI。

有人可以帮忙吗?

干杯

最佳答案

我不确定您所处的上下文,但是在WinForms中,您可以使用form.Invoke()从另一个线程访问主Form的UI线程,如下所示:

        // Assuming the following Form and method:
Form form = ...
Action method = ...

// Invoke the method like this, so it is run in the UI thread.
if (form.InvokeRequired)
{
form.Invoke(method);
}
// If we are already in the UI thread,
// just run the method without an invoke.
else
{
method();
}

关于c# - 如何在bho中的异步httpwebrequest回调中访问ui线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6829385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com