Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

use ManualResetEventSlim instead of using Thread.Sleep in a loop #582

Merged

Conversation

tmaczynski
Copy link
Contributor

@tmaczynski tmaczynski commented Apr 23, 2017

This is a minor change which eliminates anti-pattern of using Thread.Sleep() in a loop. Using Thread.Sleep() in a loop is inefficient because of unnecessary context switches and unnecessary delays that it causes.

I've found this repo by using Google BigQuery when I searched if my code analyzer is useful.

PS. I recommend viewing this PR is a in a tool that handles changes of indentation well (e.g. git plugin for VS2017).

Prerequisites:

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

@JimBobSquarePants
Copy link
Owner

Thanks for this appreciate it! 👍

BTW that analyzer is very clever. Hopefully you get the appropriate feedback soon!

@JimBobSquarePants JimBobSquarePants merged commit fef7829 into JimBobSquarePants:develop May 2, 2017
@tmaczynski
Copy link
Contributor Author

Thanks:)

To be clear: My analyzer provides code fixes only if Thread.Sleep is used in async code, this change was found by my analyzer and I changed the code myself.

@JimBobSquarePants
Copy link
Owner

Ah cool, Still clever stuff. Something I'd like to look into one day.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants