Hook Windows API in WMSG mode in fiber.

This commit is contained in:
郑树新 2024-11-09 10:47:11 +08:00
parent fde9c6316f
commit 015218bac2
4 changed files with 22 additions and 4 deletions

View File

@ -292,6 +292,8 @@ void fiber::schedule_gui()
{
acl_fiber_schedule_init(1);
acl_fiber_schedule_set_event(FIBER_EVENT_WMSG);
winapi_hook();
if (backend_fiber == NULL) {
backend_fiber = new gui_backend;
backend_fiber->start();

View File

@ -12,7 +12,6 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui_(new Ui::MainWindow)
, process_(new QProcess(this))
{
ui_->setupUi(this);
stamp_ = new struct timeval;
@ -209,6 +208,7 @@ void MainWindow::onStartSchedule()
ui_->stopSchedule->setEnabled(true);
ui_->urlGet->setEnabled(true);
ui_->startServer->setEnabled(true);
ui_->startSchedule->setEnabled(false);
qDebug() << "Begin schedule_gui!";
acl::fiber::schedule_gui();
@ -238,8 +238,12 @@ void MainWindow::onStopSchedule()
void MainWindow::onHttpOptions()
{
go[this] {
qDebug() << "Sleep 5 seconds before starting http options dialog";
acl::fiber::delay(5000);
QMessageBox::information(this, "HttpOptions", "Options Window will be opened after 5 seconds.");
ui_->progress->setValue(0);
for (int i = 1; i < 6; i++) {
acl::fiber::delay(1000);
ui_->progress2->setValue(20 * i);
}
InputDialog dialog(this);
QRect mainWindowGeometry = this->frameGeometry();

View File

@ -57,7 +57,6 @@ private:
Ui::MainWindow *ui_;
fiber_server *server_ = nullptr;
QProcess *process_;
struct timeval *stamp_;
std::string url_ = "http://www.baidu.com/";

View File

@ -245,6 +245,19 @@
</font>
</property>
</widget>
<widget class="QProgressBar" name="progress2">
<property name="geometry">
<rect>
<x>1270</x>
<y>630</y>
<width>591</width>
<height>41</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">