在指定的CEF线程上执行任务

博客介绍了如何在CEF框架的特定线程(如TID_UI、TID_RENDER)上执行任务。通过继承CefTask接口或使用base::Bind创建Functor,可以在指定线程上运行代码,例如在Browser进程中弹出窗口。详细步骤和参考资料链接提供在内容中。
摘要由CSDN通过智能技术生成

CEF有几种线程,比如TID_UI、比如TID_RENDER,每种都有特定的含义,具体类别定义在cef_types.h中,摘录如下:

typedef enum {
// BROWSER PROCESS THREADS -- Only available in the browser process.

  ///
  // The main thread in the browser. This will be the same as the main
  // application thread if CefInitialize() is called with a
  // CefSettings.multi_threaded_message_loop value of false.
  ///
  TID_UI,

  ///
  // Used to interact with the database.
  ///
  TID_DB,

  ///
  // Used to interact with the file system.
  ///
  TID_FILE,

  ///
  // Used for file system operations that block user interactions.
  // Responsiveness of this thread affects users.
  ///
  TID_FILE_USER_BLOCKING,

  ///
  // Used to launch and terminate browser processes.
  ///
  TID_PROCESS_LAUNCHER,

  ///
  // Used to handle slow HTTP cache operations.
  ///
  TID_CACHE,

  ///
  // Used to process IPC and network messages.
  ///
  TID_IO,

// RENDER PROCESS THREADS -- Only available in the rende
在VB.NET上使用CefSharp可以通过以下步骤实现: 1. 创建一个新的VB.NET项目。在Visual Studio中选择“文件”->“新建项目”,然后选择“Windows桌面应用程序”。 2. 下载和安装CefSharp。可以通过NuGet包管理器安装CefSharp。在Visual Studio中,选择“工具”->“NuGet包管理器”->“管理NuGet程序包”,然后搜索并安装“CefSharp.WinForms”和“CefSharp.Common”两个包。 3. 在VB.NET项目中添加一个WebBrowser控件。在Visual Studio的设计视图中,从工具箱中将WebBrowser控件拖放到窗体上。 4. 引入CefSharp的命名空间。在窗体类的代码中,添加以下引用: ```vb Imports CefSharp.WinForms Imports CefSharp ``` 5. 在窗体类的成员变量中声明一个ChromiumWebBrowser对象: ```vb Private browser As ChromiumWebBrowser ``` 6. 在窗体的“加载”事件中初始化ChromiumWebBrowser对象并将其添加到窗体中: ```vb Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Cef.Initialize(New CefSettings()) browser = New ChromiumWebBrowser("http://www.example.com") Me.Controls.Add(browser) End Sub ``` 这将初始化CefSharp的设置,并在WebBrowser控件中加载一个初始网址。 7. 运行项目。单击Visual Studio的“调试”->“开始调试”或按F5键来运行项目。CefSharp将在WebBrowser控件中加载指定的网页。 以上是在VB.NET上使用CefSharp的基本步骤。你可以进一步探索CefSharp的功能和选项,例如处理网页事件、执行JavaScript等。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

foruok

你可以选择打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值