代码之家  ›  专栏  ›  技术社区  ›  Levi

运行时停止Wt C++函数

  •  0
  • Levi  · 技术社区  · 7 年前

    我正在使用Wt(witty)C++框架,遇到了一个问题:如何阻止函数运行。如果单击按钮open\u doors\u按钮,则会激活功能doors\u open\u all,这需要很长时间才能完成。

    如果用户希望停止此功能的运行,则会出现问题。

        Wt::WPushButton *open_doors_button = new Wt::WPushButton("open all");
        container_box->addWidget(open_doors_button);
        open_doors_button->clicked().connect(boost::bind(&Servicemode::doors_open_all, this));
    
        Wt::WPushButton *stop_doors_button = new Wt::WPushButton("stop opening");
        container_box->addWidget(stop_doors_button);
        stop_doors_button->clicked().connect(boost::bind(&Servicemode::stop_doors_open_all, this));
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Drew Dormann    7 年前

    如果不想阻止响应Wt事件的线程,则需要在自己的线程中运行慢速函数。多线程是您所描述的。