Best practices for C# coding on the Robogator platform
To achieve the best possible result and a smooth experience, remember the following 4 practices when creating C# scripts for the Robogator platform:
// This is how we do it...
C#
- Avoid asynchronous processing. Every script runs in its own .NET Task and is automatically handled by the internal thread pool. Sync processing also allows the Robogator platform to accurately track the start and end of running Tasks
- To achieve multithreading, it's better to clone your Task and start all Tasks together, rather than trying to perform multithreading inside a single Task. This approach offers better handling, better scalability, improved error tracking, and more predictable behavior
- Ensure that your own error handling includes cancellation methods. Implement these within any long-running loop to enable Task termination in a seamless manner
- When using object-oriented programming (OOP), focus on using non-static objects and avoid relying on the class Program and Main() method entirely. The simpler, the better