Best method for putting a wait
-
Hi , What is the best method for putting a wait in execution.Thread.Sleep() will raise parasoft warnings and its not a good way to use Thread.Sleep every where.Is there any other ways ? Waith warm regards.
-
Hi , What is the best method for putting a wait in execution.Thread.Sleep() will raise parasoft warnings and its not a good way to use Thread.Sleep every where.Is there any other ways ? Waith warm regards.
Don't. If you pause your application, then your UI will stop responding. Consider instead moving any intensive work to a separate thread, or using a Timer to "wait" for when you should do something. Sleeping thread should only really be used when the thread has nothing to do until the outside world causes a change.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Don't. If you pause your application, then your UI will stop responding. Consider instead moving any intensive work to a separate thread, or using a Timer to "wait" for when you should do something. Sleeping thread should only really be used when the thread has nothing to do until the outside world causes a change.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
If I use AutoResetEvent.WaitOne() , my Static Code Analysis will throw an error for making use of the returning value of WaitOne.Confused!!!!!!!!!!! :(
-
If I use AutoResetEvent.WaitOne() , my Static Code Analysis will throw an error for making use of the returning value of WaitOne.Confused!!!!!!!!!!! :(
I can understand that. From MSDN:
Return Value
Type: System.Boolean
true if the current instance receives a signal. If the current instance is never signaled, WaitOne never returns.Clearly your SCA knows this, and deems it a waste of time checking a result that can never be false! Which of course, it is...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Hi , What is the best method for putting a wait in execution.Thread.Sleep() will raise parasoft warnings and its not a good way to use Thread.Sleep every where.Is there any other ways ? Waith warm regards.
You should almost never have an explicit wait. Instead, you should be listening for events which you want to do some action in response to. If you're waiting for another task to complete then you should use WaitHandles, but it's generally better to listen for events.
-
Hi , What is the best method for putting a wait in execution.Thread.Sleep() will raise parasoft warnings and its not a good way to use Thread.Sleep every where.Is there any other ways ? Waith warm regards.
Waiting is in general a bad idea, and timing the actions of your software is the way to madness. Can you tell us why you need to wait, or on what specifically? Are you waiting for a signal, such as user-input? Waiting until a process is finished? Waiting until there's data on the socket? If you tell us what you are waiting on, we could perhaps provide an alternative that doesn't involve waiting.
Bastard Programmer from Hell :suss: