Xandoca Active Member Licensed User Longtime User Apr 30, 2014 #1 Hi, What are the steps to create an event? My objective is: A class or object that wait n seconds and when it complete (wait n seconds) it raises the event complete, like mediaplayer complete. I want that because my app show wait some time before running the next music file. It works fine but if I try to back or forward the music that app don't respond because I've implement the wait sub like: Code: Copy Sub WaitSeconds(seconds As Int) Dim Ti As Long Ti = DateTime.Now + (seconds * 1000) Do While DateTime.Now < Ti DoEvents Loop End Sub Thanks
Hi, What are the steps to create an event? My objective is: A class or object that wait n seconds and when it complete (wait n seconds) it raises the event complete, like mediaplayer complete. I want that because my app show wait some time before running the next music file. It works fine but if I try to back or forward the music that app don't respond because I've implement the wait sub like: Code: Copy Sub WaitSeconds(seconds As Int) Dim Ti As Long Ti = DateTime.Now + (seconds * 1000) Do While DateTime.Now < Ti DoEvents Loop End Sub Thanks
stevel05 Expert Licensed User Longtime User Apr 30, 2014 #2 Use a Timer, the Timer _Tick callback is your completed event. Upvote 0
Xandoca Active Member Licensed User Longtime User Apr 30, 2014 #3 stevel05 said: Use a Timer, the Timer _Tick callback is your completed event. Click to expand... Thanks! I have to implement it on a service. I've try but it seems to work only with activities. Is there another option or I'm doing something wrong? Best Regards. Upvote 0
stevel05 said: Use a Timer, the Timer _Tick callback is your completed event. Click to expand... Thanks! I have to implement it on a service. I've try but it seems to work only with activities. Is there another option or I'm doing something wrong? Best Regards.
thedesolatesoul Expert Licensed User Longtime User Apr 30, 2014 #4 Timers work in services as well. A service may however be killed after a while. You can use a foreground or sticky service to keep it alive. Upvote 0
Timers work in services as well. A service may however be killed after a while. You can use a foreground or sticky service to keep it alive.
Xandoca Active Member Licensed User Longtime User May 1, 2014 #5 Thank you guys. The problem was I've put the timer on a code module and then call it from a service. It doesn't work. I put the timer in the service and it works. Upvote 0
Thank you guys. The problem was I've put the timer on a code module and then call it from a service. It doesn't work. I put the timer in the service and it works.
thedesolatesoul Expert Licensed User Longtime User May 1, 2014 #6 Yes, events cannot be raised in code modules as they are not an 'active' module, just a bunch of code. Upvote 0
Yes, events cannot be raised in code modules as they are not an 'active' module, just a bunch of code.