【问题标题】:Multi Threading in AX 2012 X++AX 2012 X++ 中的多线程
【发布时间】:2017-12-12 10:14:37
【问题描述】:

我们中的许多人都在经历 AX 2012 中的优化问题。在许多情况下,与流程相关的代码中的优化问题没有解决方案,就像我们在报告中有许多其他方法一样。

案例:我有一个案例,我必须在 AX 2012 中单击一个按钮来确认多个销售订单。在确认该销售订单后,我们需要执行一些其他“定制”流程,这是在遵循代码实践和最大限度地优化编码方法之后的一个有点冗长的过程。所以我对如何通过多线程处理这种情况有一个疑问

【问题讨论】:

  • 有人在一分钟内回答自己不是问题
  • @DAXaholic 实际上,允许甚至鼓励自我回答:stackoverflow.com/help/self-answer
  • 哦不知道这个sry。有点奇怪,但这只是我的意见。感谢您指出这一点!

标签: multithreading axapta dynamics-ax-2012 x++ dynamics-ax-2012-r3


【解决方案1】:

Introduction to the SysOperation Framework 提供了如何在 AX2012 中并行化代码的具体示例(示例计算素数)。

此外,还有一系列出色的帖子,名为 Batch Parallelism in AX part IIIIIIIV,提供了如何将“线程”与批处理任务最佳匹配的分析。

【讨论】:

    【解决方案2】:

    不要直接使用multi threading。它是一种客户端技术。

    在 Axatpa 中使用batch processing 框架。它是在服务器上具有多线程的服务器技术。 https://msdn.microsoft.com/en-us/library/gg243235.aspx

    这对开发人员意味着:创建您的类并从 RunBasBatch 扩展它(参见 AOT 中的 Tutorial_RunBaseBatch 类)或 SysOperation https://msdn.microsoft.com/en-us/library/gg862488.aspx

    【讨论】:

      【解决方案3】:

      我在 Ax2012 中通过 Thread 类了解了使用多线程的特性,然后我尝试按照以下方式实现。

      您首先需要在类的静态方法中实现所有逻辑。该静态方法应包含线程类作为参数,例如

      public static void process(thread _thread)
      {
          FG_ConfirmationEngine   confirmationEngine = new FG_ConfirmationEngine();
          salesTable              salesTable;
          container               _con;;
          _con = _thread.getInputParm();
          info(conPeek(_thread.getInputParm(),1));
          salesTable = salesTable::find(conPeek(_thread.getInputParm(),1));
          confirmationEngine.parmSalesTable(salesTable);
          confirmationEngine.run();// in this method all of my confirmation pre and post logic exist
      }
      

      在类中创建该静态方法后,您需要编写该方法的调用。 注意:您不能通过 Thread 类发送任何 Args、Object。只能通过_thread.setInputParm([salestable.salesid])方法等thread.setInputParm()方法以容器形式发送参数。

      来电:

      salesline                   salesline;
      ExecutePermission           perm;
      Thread                      myThread;
      ttsBegin;
      
      perm = new ExecutePermission();
      
      if (!perm)
      return;
      
      perm.assert();
      
      while select salesid from salestable
          where salestable.FG_BookingReferenceID == "BRF-0001"
      {
          myThread = new Thread();
          myThread.setInputParm([salestable.SalesId]);
          if (myThread)
          {
              myThread.removeOnComplete(true);
              myThread.run(classnum(FG_ConfirmationEngine), staticMethodStr(FG_ConfirmationEngine,process));
          }
      }
      
      CodeAccessPermission::revertAssert();
      

      希望对您有所帮助。快乐大兴

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多