vbmundo Well-Known Member Licensed User Jun 23, 2016 #1 Hi, I see calls to other routines or subs is not in real time, ie when the line of code finds a CallSub should immediately move the pointer execution to the desired routine and then return to the next instruction of the call. It's what all programming languages does. I'm running the debugger and I see that after a CallSubDelayed control code stay in the calling routine follow and run after the so-called instructions, long before running the routine call. It's simply.. How can I use Functions in Services that starts when were called How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ? Regards
Hi, I see calls to other routines or subs is not in real time, ie when the line of code finds a CallSub should immediately move the pointer execution to the desired routine and then return to the next instruction of the call. It's what all programming languages does. I'm running the debugger and I see that after a CallSubDelayed control code stay in the calling routine follow and run after the so-called instructions, long before running the routine call. It's simply.. How can I use Functions in Services that starts when were called How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ? Regards
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2016 #2 Don't confuse CallSubDelayed and CallSub. CallSub called the method immediately. CallSubDelayed sends a message to the message queue which calls the sub when the message is processed. Using CallSubDelayed to interact between activities and services vbmundo said: How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ? Click to expand... Pass an array or Map as one of the parameters. Code: CallSub2(MyService, "MySub", CreateMap("X": 100, "Y": 200)) ... Sub MySub(args As Map) Dim x As Int = args.Get("X") End Sub Upvote 0
Don't confuse CallSubDelayed and CallSub. CallSub called the method immediately. CallSubDelayed sends a message to the message queue which calls the sub when the message is processed. Using CallSubDelayed to interact between activities and services vbmundo said: How can I use Functions with more than 2 parameters.... CallSubDelayed2 , CallSubDelayed3 ? Click to expand... Pass an array or Map as one of the parameters. Code: CallSub2(MyService, "MySub", CreateMap("X": 100, "Y": 200)) ... Sub MySub(args As Map) Dim x As Int = args.Get("X") End Sub
vbmundo Well-Known Member Licensed User Jun 23, 2016 #3 Erel said: Don't confuse CallSubDelayed and CallSub. CallSub called the method immediately. CallSubDelayed sends a message to the message queue which calls the sub when the message is processed. Using CallSubDelayed to interact between activities and services Pass an array or Map as one of the parameters. Code: CallSub2(MyService, "MySub", CreateMap("X": 100, "Y": 200)) ... Sub MySub(args As Map) Dim x As Int = args.Get("X") End Sub Click to expand... Thanks Erel, But I need to use Callsub to interact between Activities and Services... NOT CallSubDelayed.. I need to run inmediately, because the rest of execution dependes of Services results. I'm using DonMamfred MySQL Lib, and he recomend to me that every Routines need to be in a Service... I have all in the Activity and work fine... but as Best Practice, I could migrate all main code to a Service.. but this idea still does not convince me at all I need each command is executed sequentially, not everything can be asynchronous But I want to learn to use the best way B4A Thanks Erel Upvote 0
Erel said: Don't confuse CallSubDelayed and CallSub. CallSub called the method immediately. CallSubDelayed sends a message to the message queue which calls the sub when the message is processed. Using CallSubDelayed to interact between activities and services Pass an array or Map as one of the parameters. Code: CallSub2(MyService, "MySub", CreateMap("X": 100, "Y": 200)) ... Sub MySub(args As Map) Dim x As Int = args.Get("X") End Sub Click to expand... Thanks Erel, But I need to use Callsub to interact between Activities and Services... NOT CallSubDelayed.. I need to run inmediately, because the rest of execution dependes of Services results. I'm using DonMamfred MySQL Lib, and he recomend to me that every Routines need to be in a Service... I have all in the Activity and work fine... but as Best Practice, I could migrate all main code to a Service.. but this idea still does not convince me at all I need each command is executed sequentially, not everything can be asynchronous But I want to learn to use the best way B4A Thanks Erel
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2016 #4 vbmundo said: But I need to use Callsub to interact between Activities and Services... NOT CallSubDelayed.. I need to run inmediately, because the rest of execution dependes of Services results. Click to expand... So use CallSub. Upvote 0
vbmundo said: But I need to use Callsub to interact between Activities and Services... NOT CallSubDelayed.. I need to run inmediately, because the rest of execution dependes of Services results. Click to expand... So use CallSub.
vbmundo Well-Known Member Licensed User Jun 23, 2016 #6 DonManfred said: My name is Manfred!!! Click to expand... Sorry friend.. Manfred. Upvote 0
vbmundo Well-Known Member Licensed User Jun 23, 2016 #7 Erel said: So use CallSub. Click to expand... But I read that CallSub not work to call a Sub of a Service. and I taste it and not run effectively. Upvote 0
Erel said: So use CallSub. Click to expand... But I read that CallSub not work to call a Sub of a Service. and I taste it and not run effectively.
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2016 #8 CallSub does work. The main difference is that CallSubDelayed will start the service or activity if it is not already started. CallSub will not do anything if the service wasn't started before. Note that calling StartService doesn't immediately start the service. Upvote 0
CallSub does work. The main difference is that CallSubDelayed will start the service or activity if it is not already started. CallSub will not do anything if the service wasn't started before. Note that calling StartService doesn't immediately start the service.
vbmundo Well-Known Member Licensed User Jun 23, 2016 #9 Erel said: CallSub does work. The main difference is that CallSubDelayed will start the service or activity if it is not already started. CallSub will not do anything if the service wasn't started before. Note that calling StartService doesn't immediately start the service. Click to expand... How can I start all Services by code in Main code ? Regards Upvote 0
Erel said: CallSub does work. The main difference is that CallSubDelayed will start the service or activity if it is not already started. CallSub will not do anything if the service wasn't started before. Note that calling StartService doesn't immediately start the service. Click to expand... How can I start all Services by code in Main code ? Regards
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2016 #10 The correct place to do it is from the Starter service: Starter Service - Consistent & Single Entry Point You can use StartService to start your services. Upvote 0
The correct place to do it is from the Starter service: Starter Service - Consistent & Single Entry Point You can use StartService to start your services.
vbmundo Well-Known Member Licensed User Jun 23, 2016 #11 Erel said: The correct place to do it is from the Starter service: Starter Service - Consistent & Single Entry Point You can use StartService to start your services. Click to expand... Perfect Erel (as allways).. Thanks Upvote 0
Erel said: The correct place to do it is from the Starter service: Starter Service - Consistent & Single Entry Point You can use StartService to start your services. Click to expand... Perfect Erel (as allways).. Thanks