locked
race simulation - help with implementation details? RRS feed

  • Question

  • User-251496785 posted

    I have a task to write a car race simulation. My problem with the implementation is this: I know that I will have an Race object that has all the properties needed. But how can I make it run in background and update it while it's running? I need to have API calls that return race status in that moment. For an example, one call would return the leaderboard, one call would return race status(pending, running, finished). How would I implement this? Can you please point me in the right direction. Should I use threads? When the race starts should there be one thread that has the race object? And if so, how will I update it's status and leaderboard? Can I maybe implement microservices here? Any help would be appreciated.

    Thanks in advance

    Wednesday, March 31, 2021 10:00 AM

Answers

  • User475983607 posted

    tricman10

    How would I create race simulation in the background?

    First you have to come up with requirements, then document the design, finally write the simulation.  Running an application in the background is a matter of starting a tread to run the simulation or maybe an IHostedService.  I assume the simulation is a console application or a service pattern since Web API does not have a UI.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 31, 2021 2:10 PM

All replies

  • User475983607 posted

    Write a race car simulation that runs in the background.  The simulation updates static variables that holds the current state of the race.  The Web API action reads the current state and returns the results. 

     

    Wednesday, March 31, 2021 11:31 AM
  • User-251496785 posted

    How would I create race simulation in the background?

    Wednesday, March 31, 2021 1:16 PM
  • User475983607 posted

    tricman10

    How would I create race simulation in the background?

    First you have to come up with requirements, then document the design, finally write the simulation.  Running an application in the background is a matter of starting a tread to run the simulation or maybe an IHostedService.  I assume the simulation is a console application or a service pattern since Web API does not have a UI.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 31, 2021 2:10 PM