Android Question Call B4A sub from library

Discussion in 'Android Questions' started by kiki78, Feb 17, 2015.

  1. kiki78

    kiki78 Active Member Licensed User

    I want to construct Runnable in java library that call B4A code.
    But I never found the way to do that.

    For example I expect to pass object that contain sub and string with sub name and have a constructor to make runnable with that .

    Does some one put me on right way ?

  2. Erel

    Erel Administrator Staff Member Licensed User

    Raise an event from your library.
    xiaoyao likes this.
  3. kiki78

    kiki78 Active Member Licensed User

    Thank you Erel,
    I already consider that as workaround.
    But as I never know in advance the function name is it possible, for example, to construct Runnable object in Basic side and pass it to library ?

  4. Erel

    Erel Administrator Staff Member Licensed User

    All the libraries raise events without knowing the sub name which is set with the EventName parameter.
  5. kiki78

    kiki78 Active Member Licensed User

    Thank you Erel,
    My question is not how to raise events, but how to call Basic function without using BA raiseevent method, if it's possible.
    In BA, I see method runHook but I never found doc.

  6. Erel

    Erel Administrator Staff Member Licensed User

    Why don't you want to use raiseEvent like all other libraries?
  7. kiki78

    kiki78 Active Member Licensed User

    So I explain more my project.

    I do intensive calculation.
    Code is write in Basic, originally .NET then translate to B4A.
    In .NET I use Parallel.For to distribute calculation in multiple thread and better use multi-core processor.
    In B4A I make a class for ParallelFor in Basic using Agraham Threading library.
    Each class of my math library (vector, matrix, etc...) have property to associate, or not, instance of ParalleleFor class then this is propagate to results.

    But this implementation in Basic it's not really efficient, so I try to use java.util.concurrent.

    For now I test it with raiseEvent, and it's already better, but to correctly distribute call, I need to have Basic + Java library with this step :
    - Receive call to Basic ParallelFor class with function name, container and list of item to loop.
    - Call Java ParallelFor class for launching concurrent thread that raiseEvent and wait termination.
    - Receive events in Basic ParallelFor class to callback correct calculation function.

    If I can directly call basic function from Java code, I can completely remove Basic part and I expect better result.

    I expect it's more clear now.
  8. DonManfred

    DonManfred Expert Licensed User

    Yes. Use Raiseevent! It is nothing more than calling your b4a sub....
    thedesolatesoul likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice