AX 2012 X ++中的多线程

问题描述 投票:2回答:3

我们中的许多人正在审查AX 2012中的优化问题。在许多情况下,流程相关代码中的优化问题没有像我们在报告中有许多其他方法那样的解决方案。

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

multithreading axapta dynamics-ax-2012 x++ dynamics-ax-2012-r3
3个回答
5
投票

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


1
投票

我已经了解了在Ax2012中使用Thread类使用多线程的功能,然后我尝试按以下方式实现。

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

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()方法(如_thread.setInputParm([salestable.salesid])方法)以容器的形式发送参数。

呼叫:

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();

希望能帮助到你。快乐的DAXing

© www.soinside.com 2019 - 2024. All rights reserved.