Hello, welcome back.
In this lesson, we shall see how to stop our auto reload the timer.
In a previous lesson, we saw how to create the auto reload on the one short timer and we saw the difference.
I'm going to make a copy of the last project.
Should I explain from there?
We have twenty three over here working with time as software time.
It says, I'm going to copy and paste over here and rename this.
Stopping the timer or just call it stopping the timer, okay?
Right, here we are.
This is.
We may not see fall over here.
And we created two time as a one stop time and an auto reload time at the one stop timer.
Or the one short timer we said issued should OK was issued OK after four thousand milliseconds and we
said the auto reload time should OK every five hundred milliseconds.
So the question is it's going to OK every five hundred milliseconds.
How are we going to stop it if we want to stop it?
Well what we could do is we could just put a counter variable in the in the callback function of the
auto reload timer such that when the count variable reaches a particular number, we can stop the timer.
So I can come over here.
And then I can see you ain't.
I can create a variable you in 30 to 40 and then see.
Time outs can't remember the callback function is going to occur every five hundred milliseconds at
time out of every five hundred hours, so time out, can't hear.
I can initialize this to zero.
OK.
And then come in here and see, OK?
Whenever this happens, I'm going to increment time out and then I could check if the time out Ecorse
10 such that let's see if we've had we want to stop this timer after ten timeout.
So I could see if time out here.
We want to stop it if the timeout is equal to 10, if timeout is is.
Because of was 10, we can simply see I can define a value here.
You inserted to underscore T.
I can make this constant.
I can call this.
Stop, Mark, something like this, and this is OK.
So I can see.
If Time article stop Mark, then.
We can simply call our X time to stop function.
And the next time I stop function.
Just takes the, uh, it looks similar to our next time I start.
So over here, it's time to stop.
It takes one argument, the handle of the timer, so I change this word starts to stop OK, like this,
right.
And then we can print something.
If we could say.
Stop, Mark.
Reached.
Of what the cops look suspicious.
And then we see percentage Delva here, carriage return, new line, and then we can still print the
current value.
So that we know when the stock market reached OK?
Today, and then we stop the timer, let's click over here to build.
Right, click.
Huge project over here.
It's in.
Uh, uh, there's an anomaly, of course.
I wonder why the cops came on OK, stop should be spelled this way over here to build.
There's another anomaly.
OK, so our next time I stop API, OK, we need to indicates the block time as well.
It takes two arguments to block time.
Over here, we pass in a blocked time of zero.
OK, let's build a click over here to build.
It's built successfully.
All right, click over here and then.
S. Debuggers Ystem 32, select twenty four Aubagio.
And I'll see, OK, over here.
It's opening the debark for you.
Click switch over here.
And I'm going to make space.
Click here.
Me, this I'm going to open real to.
I'm going to select new line mode over here.
So like a portrait.
This one here, then, how old is this?
And I'm going to click to Open and then I'll click to run.
OK, so time is running.
OK, so you see, stop, Mark reached at five thousand.
Of course, we said after ten executions of the callback function, we should stop and if 500 EMS,
OK is ten times, we end up with five thousand.
OK, so this is a way that you can stop your timer during runtime.
OK, so this order is for the short lesson and I'll see you the next lesson.
Have a nice day.