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

标签 c# multithreading bho

我正在努力访问浏览器帮助程序对象中异步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/

相关文章:

c# - 帮助破译 logcat 输出 - 过多的 JNI 全局引用

c# - 获取列表中的最大 KeyValuePair<KeyValuePair>

python - 在 Python 中排队线程

c# - Monitor.Wait() 是否仍然调用上下文切换?

c++ - IE8 的附加组件仅在我从 Visual Studio 调试时可见

C# 重载属性

c# - Fluent NHibernate 映射到 SQL Server CHAR(10) ID 列

java - 线程之间的通信

c# - BHO 在每个页面上执行 JavaScript

c++ - 无法启动程序 ATL Project C++