Beyond the specifics for your question, you ask:
I have already created a possible solution but I am not sure if my solution is considered "good practice" or if there are any edge cases when my code will not work the way it should
Could I therefore please get some feedback on my idea? Is it good? Can it still be improved?
These questions are not a good fit for this kind of site. They are too broad and opinionated. "Best practice" questions are almost always primarily opinion based, and tend to be closed as such.
Questions should be specific and practical. E.g.:
- "How do I do X, using Y?".
- "Why while trying to do X using Y, I get Foo when I expect Bar?"
Asking for other users to review code and give their opinions is not a good way to use the site, and will get you poor results and a poor experience.
Let's try to see what else we can learn from this question for the future.
Say we remove all that. What are we left with?
The title of the linked question is "How to run some code at certain times every day?". Using the task scheduler is a perfectly valid answer to that. If that's not a valid answer, for any reason, you should specify that in your question; so that potential answerers know of your specific constraints.
Scope and constraints are vital to get useful answers.
Your future questions should state up-front what specific constraints are you facing. Sometimes, even why you are facing these constraints (succinctly). If your constraints are very unusual, they may confuse your potential answerers if you do not explain them.
You do get into these constraints in the comments. Do not do that. Comments are mostly so other users can ask you for additional info and clarification about your post. Add that information in the body of your question, do not get entangled in comments.
The question needs to be complete. Comments are supplementary and should be considered ephemeral for most purposes.
Reading further, it doesn't look like you want to "run code at certain times", but that you specifically want to run an infinite loop, and conditionally execute the body of the loop, the condition being the time of the day.
It's important that the question title better communicate the specific issue.
Finally, it looks you have a "working" solution; but you simply want other user's opinions on it. This brings us back to the beginning:
This is simply not a good site for that kind of question. If you were facing specific problems with your solution, you could write a question about those.
But asking users to review code, or if a specific implementation is considered good practice or not (or good or bad), it's not a good use of the site.
Use this as a learning experience, take some time to read what the help-center has to say on "asking questions", and your next efforts will be much better received.