<i id='WRD45'><tr id='WRD45'><dt id='WRD45'><q id='WRD45'><span id='WRD45'><b id='WRD45'><form id='WRD45'><ins id='WRD45'></ins><ul id='WRD45'></ul><sub id='WRD45'></sub></form><legend id='WRD45'></legend><bdo id='WRD45'><pre id='WRD45'><center id='WRD45'></center></pre></bdo></b><th id='WRD45'></th></span></q></dt></tr></i><div id='WRD45'><tfoot id='WRD45'></tfoot><dl id='WRD45'><fieldset id='WRD45'></fieldset></dl></div>
      <legend id='WRD45'><style id='WRD45'><dir id='WRD45'><q id='WRD45'></q></dir></style></legend><tfoot id='WRD45'></tfoot>
        <bdo id='WRD45'></bdo><ul id='WRD45'></ul>

    1. <small id='WRD45'></small><noframes id='WRD45'>

    2. 在 C++ 中进行事件处理的正确方法是什么?

      时间:2023-09-17
      <tfoot id='2DysO'></tfoot>

          <legend id='2DysO'><style id='2DysO'><dir id='2DysO'><q id='2DysO'></q></dir></style></legend>
          <i id='2DysO'><tr id='2DysO'><dt id='2DysO'><q id='2DysO'><span id='2DysO'><b id='2DysO'><form id='2DysO'><ins id='2DysO'></ins><ul id='2DysO'></ul><sub id='2DysO'></sub></form><legend id='2DysO'></legend><bdo id='2DysO'><pre id='2DysO'><center id='2DysO'></center></pre></bdo></b><th id='2DysO'></th></span></q></dt></tr></i><div id='2DysO'><tfoot id='2DysO'></tfoot><dl id='2DysO'><fieldset id='2DysO'></fieldset></dl></div>

                <tbody id='2DysO'></tbody>

              <small id='2DysO'></small><noframes id='2DysO'>

              • <bdo id='2DysO'></bdo><ul id='2DysO'></ul>

                本文介绍了在 C++ 中进行事件处理的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个应用程序需要以下列方式响应某些事件:

                I have an application that needs to respond to certain events in the following manner:

                void someMethodWithinSomeClass() {
                    while (true) {
                        wait for event;
                        if (event == SomeEvent) {
                            doSomething();
                            continue;
                        }
                        if (event == SomeOtherEvent) {
                            doSomethingElse();
                            continue;
                        }
                    } 
                }
                

                这将是一些线程运行.在其他一些线程中,操作将创建和触发事件.

                This would be running is some thread. In some other threads, operations would create and fire the Events.

                如何让这些事件到达上述方法/类?在 C++ 中实现事件处理的正确策略或架构是什么?

                How do I get these Events to reach the above method/class? What is the proper strategy or architecture for implementing event handling in C++?

                推荐答案

                C++ 标准根本不处理事件.但是,通常情况下,如果您需要事件,您将在提供它们的框架内工作 (SDL、Windows、Qt、GNOME 等)以及等待、调度和使用它们的方法.

                The C++ Standard doesn't address events at all. Usually, however, if you need events you are working within a framework that provides them (SDL, Windows, Qt, GNOME, etc.) and ways to wait for, dispatch and use them.

                除此之外,您可能还想查看 Boost.Signals2.

                Aside from that, you may want to look at Boost.Signals2.

                这篇关于在 C++ 中进行事件处理的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:c++ - 当c ++未指定结构布局时,为什么glBufferData可 下一篇:在 Mac OS X 上模拟鼠标点击对某些应用程序不起作

                相关文章

                最新文章

              • <small id='AhS2o'></small><noframes id='AhS2o'>

                <i id='AhS2o'><tr id='AhS2o'><dt id='AhS2o'><q id='AhS2o'><span id='AhS2o'><b id='AhS2o'><form id='AhS2o'><ins id='AhS2o'></ins><ul id='AhS2o'></ul><sub id='AhS2o'></sub></form><legend id='AhS2o'></legend><bdo id='AhS2o'><pre id='AhS2o'><center id='AhS2o'></center></pre></bdo></b><th id='AhS2o'></th></span></q></dt></tr></i><div id='AhS2o'><tfoot id='AhS2o'></tfoot><dl id='AhS2o'><fieldset id='AhS2o'></fieldset></dl></div>
                  • <bdo id='AhS2o'></bdo><ul id='AhS2o'></ul>

                  1. <legend id='AhS2o'><style id='AhS2o'><dir id='AhS2o'><q id='AhS2o'></q></dir></style></legend>
                  2. <tfoot id='AhS2o'></tfoot>