Multi-Threading Prompts
AI prompts for multi-threading from the LearnWithHasan AI Coding Building Blocks (Performance).
Move a Task to Background Thread
Start here. The most common threading fix From the Multi-Threading AI Coding Building Block.
My [desktop app / Electron app / mobile app] freezes when I click the button that [downloads a file / processes images / queries a database / loads data]. Move this task to a background thread so the UI stays responsive. While the task runs: - Show a loading spinner or progress bar - Keep all buttons and UI elements clickable - When the task finishes, update the UI with the results - If the task fails, show an error message without crashing My stack: [your language and framework here, e.g. Python + Tkinter, C# + WinForms, Java + Swing, Electron] I'm learning, so explain each part simply.
Add Progress Bar with Background Thread
For tasks where users need to see progress From the Multi-Threading AI Coding Building Block.
I have a long-running task in my [app] that [processes files / converts data / downloads multiple items]. I want to show real-time progress to the user. Set up a background thread that: - Runs the task without freezing the UI - Reports progress back to the main thread (percentage or step count) - Updates a progress bar smoothly as the task advances - Allows the user to cancel the task mid-way - Shows "Done!" when complete and re-enables the start button My stack: [your language and framework here] I'm learning, so explain each part simply.
Run Multiple Tasks Without Freezing
For apps juggling multiple long operations From the Multi-Threading AI Coding Building Block.
My [app] needs to run several long tasks at once: [list your tasks, e.g. download files + process images + sync data]. Right now they run one after another and the UI freezes the whole time. Create a system that: - Runs each task on its own background thread (or uses a thread pool) - Shows individual status for each task (waiting / running / done) - Keeps the UI fully responsive throughout - Updates the screen safely from background threads (no crashes) - Handles errors in one task without stopping the others My stack: [your language and framework here] I'm learning, so explain each part simply.