Marcos Alves Well-Known Member Licensed User Longtime User May 29, 2018 #1 Suppose that I want to destroy and recreate a service calling from itself. What is the correct order ? This: Code: Copy StopService(Me) StartService(Me) Or This ? Code: Copy StartService(Me) StopService(Me)
Suppose that I want to destroy and recreate a service calling from itself. What is the correct order ? This: Code: Copy StopService(Me) StartService(Me) Or This ? Code: Copy StartService(Me) StopService(Me)
Erel B4X founder Staff member Licensed User Longtime User May 29, 2018 #2 Both commands send a message to the message queue. I don't see any good reason to destroy and recreate a service. It sounds to me that you are doing something wrong. The correct order is: Code: Copy StopService(Me) Sleep(300) StartService(Me) However you shouldn't do it. Upvote 0
Both commands send a message to the message queue. I don't see any good reason to destroy and recreate a service. It sounds to me that you are doing something wrong. The correct order is: Code: Copy StopService(Me) Sleep(300) StartService(Me) However you shouldn't do it.
LucaMs Expert Licensed User Longtime User May 29, 2018 #3 StartService(me) (moreover having stopped it) would work? And where would you write this command? Upvote 0
Marcos Alves Well-Known Member Licensed User Longtime User May 29, 2018 #4 Erel said: Both commands send a message to the message queue. I don't see any good reason to destroy and recreate a service. It sounds to me that you are doing something wrong. The correct order is: Code: Copy StopService(Me) Sleep(300) StartService(Me) However you shouldn't do it. Click to expand... Thanks @Erel , That's because I need to recreate a service in order to restart the Service_Create sub in certain conditions... maybe the follow code should be more elegant: Code: Copy Sub Service_Create CreateRoutine end Sub Sub CreateRoutine If condition then do something... ' This code will do something that will turn the condition false sometime, stopping the loop... ... CreateRoutine else StopService(Me) end if end Sub What do you think @Erel ? Upvote 0
Erel said: Both commands send a message to the message queue. I don't see any good reason to destroy and recreate a service. It sounds to me that you are doing something wrong. The correct order is: Code: Copy StopService(Me) Sleep(300) StartService(Me) However you shouldn't do it. Click to expand... Thanks @Erel , That's because I need to recreate a service in order to restart the Service_Create sub in certain conditions... maybe the follow code should be more elegant: Code: Copy Sub Service_Create CreateRoutine end Sub Sub CreateRoutine If condition then do something... ' This code will do something that will turn the condition false sometime, stopping the loop... ... CreateRoutine else StopService(Me) end if end Sub What do you think @Erel ?
Marcos Alves Well-Known Member Licensed User Longtime User May 29, 2018 #5 LucaMs said: StartService(me) (moreover having stopped it) would work? And where would you write this command? Click to expand... Yes, work. See my answer to @Erel explaining why do I need this commands. Upvote 0
LucaMs said: StartService(me) (moreover having stopped it) would work? And where would you write this command? Click to expand... Yes, work. See my answer to @Erel explaining why do I need this commands.
Erel B4X founder Staff member Licensed User Longtime User May 30, 2018 #6 Marcos Alves said: What do you think @Erel ? Click to expand... I think that it is a mistake to restart the service. I don't see any good reason for this. If you want to restart something in the service then move the relevant code to a different sub (out of Service_Create) and call it from Service_Create and when you want to restart it. Upvote 0
Marcos Alves said: What do you think @Erel ? Click to expand... I think that it is a mistake to restart the service. I don't see any good reason for this. If you want to restart something in the service then move the relevant code to a different sub (out of Service_Create) and call it from Service_Create and when you want to restart it.