Skip to Content

Running multiple Application inside one Addon

I am using SAP Business One 9.2 SDK UI and DI API in C# to write an addon which executes business logic and creates numerous forms on many parts of B1. I am thinking about making it modular, so every module has its own event handlers, menu registers and event filters. Is it a good idea to create multiple SAPbouiCOM.Application instances and pass them to the modules? Let's say I have 10-20 different modules and they subscribe to different Application.*events* and set different Application.SetFilters(). Will It slow down B1 like If I am running too many addons?

Edit.: All the modules register their events on the same thread and created on the same thread, becouse the SDK is single threaded/ not thread safe.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 23, 2016 at 10:22 AM

    Hi Szabolcs,

    The SAPbouiCOM.Application object is created when you connect with B1. You shouldn't create many connections (issues with memory and speed will rise).

    You can create a connection and pass the created application object to your modules, they can then register their events with that application object. On a side note, you should probably pass also the SAPbobsCOM.Company to your modules.

    When registering directly with the application object you'll have to manage the bubbleEvent flag carefully.

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 25, 2016 at 11:50 AM

    You're right because you are registering with the application object event.

    You can raise your own event (same arguments, except for the out bubbleEvent, make it a simple argument).

    You can then use stopEvent &= true or false; in your handlers.

    Finally, assign your bubbleEvent to B1's BubbleEvent.

    pseudo code:

    ... OnItemEvent(ItemEvent pVal, out bool BubbleEvent)
    bool stopEvent; 
    RaiseMyItemEvent(pVal, ref stopEvent); 
    BubbleEvent = stopEvent;

    Does it make sense?

    ps: sorry about the poor indenting but this new editor is getting on my nerves (I wrote this reply twice now).

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded