microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.39k stars 6.56k forks source link

Replace Thread.Sleep with task.Delay #7427

Open alekhyareddy28 opened 4 years ago

alekhyareddy28 commented 4 years ago

Performance Improvement of PT Run

Similar to PR #7401, replacing Thread.Sleep with Task.Delay throughout the codebase would improve the performance of PT Run as Thread.Sleep blocks the thread that it is called on whereas Task.Delay uses a timer instead and schedules a thread to resume work after the interval has passed. This does not block the thread.

crutkas commented 4 years ago

From the current snapshot in master, here is the offenders

image

Jay-o-Way commented 6 months ago

image The use of Thread.Sleep has increased enormously. Note that MouseWithoutBorders uses values like 1000, 5000 and even 30'000.