From the Doc:
Thread.Sleep (Int32) Suspends the current thread for a specified time.
Thread.Sleep (TimeSpan) Blocks the current thread for a specified time.
Do these have the same effect. That is, do the words "Blocks" and Suspends"
mean the same or different things.
Thanks in advance 10 1425
These are the same.
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Thanks
Are they better to use then
Do Until VB.Now EndTime
Application.DoEvents()
Loop
"Dick Grier" <dick_grierNOSPAM@.msn.comwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
These are the same.
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Franky wrote:
Are they better to use then
Do Until VB.Now EndTime
Application.DoEvents()
Loop
Yes!!
The above will drive the CPU usage of your machine through the roof,
even though it still allows other processes to run.
Thread.Sleep() actually suspends the current thread, so it uses
[virtually] no CPU.
Regards,
Phill W.
Thanks, good to know
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:el**********@south.jnrs.ja.net...
Franky wrote:
>Are they better to use then
>Do Until VB.Now EndTime Application.DoEvents() Loop
Yes!!
The above will drive the CPU usage of your machine through the roof, even
though it still allows other processes to run.
Thread.Sleep() actually suspends the current thread, so it uses
[virtually] no CPU.
Regards,
Phill W.
Hi,
The answer, like many is, "This depends (on what you want your application
to do)." However, I'd say, in general, that Sleep should be used.
Application.DoEvents has a lot of overhead, especially in a loop. However,
if you want the message pump in your app to respond to messages during the
delay, then you must use DoEvents (I often put both DoEvents AND Sleep
inside the loop).
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Franky wrote:
Thanks
Are they better to use then
Do Until VB.Now EndTime
Application.DoEvents()
Loop
Franky,
Are you wanting to block a UI thread? If so then this would be less
bad than Thread.Sleep, but it's still a bad idea. Consider an
alternate approach. Can you explain a bit more about your problem?
Brian
What could be wrong with Thread.Sleep, except that the app becomes
non-responsive??
Thanks
"Brian Gideon" <br*********@yahoo.comwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
>
Franky wrote:
>Thanks
Are they better to use then Do Until VB.Now EndTime
Application.DoEvents()
Loop
Franky,
Are you wanting to block a UI thread? If so then this would be less
bad than Thread.Sleep, but it's still a bad idea. Consider an
alternate approach. Can you explain a bit more about your problem?
Brian
I understand
Thanks
"Dick Grier" <dick_grierNOSPAM@.msn.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi,
The answer, like many is, "This depends (on what you want your application
to do)." However, I'd say, in general, that Sleep should be used.
Application.DoEvents has a lot of overhead, especially in a loop.
However, if you want the message pump in your app to respond to messages
during the delay, then you must use DoEvents (I often put both DoEvents
AND Sleep inside the loop).
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Franky wrote:
What could be wrong with Thread.Sleep, except that the app becomes
non-responsive??
Thanks
Well, that is the problem. If called on non-UI thread it would be a
different story.
Brian
Good, thanks
"Brian Gideon" <br*********@yahoo.comwrote in message
news:11**********************@t46g2000cwa.googlegr oups.com...
>
Franky wrote:
>What could be wrong with Thread.Sleep, except that the app becomes non-responsive??
Thanks
Well, that is the problem. If called on non-UI thread it would be a
different story.
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Keyee Hsu |
last post by:
Hi, I have a C# app that creates an AppDomain, enters it, and spawns an
asyn thread to do some work and then block itself. Upon the completion
of the work, the async thread supposedly terminates,...
|
by: [Yosi] |
last post by:
Hi,
I create a thread which load DLL and have DLL function call,this Dll
function takes a lot of time.
My Question is , if I request Thread.Susspend(), and the thread is inside
the Dll function...
|
by: Joe |
last post by:
Does anyone know the difference, in practical terms, between
Thread.Sleep (10000) and Thread.CurrentThread.Join (10000)??
The MSDN says that with Join, standard COM and SendMessage pumping...
|
by: k.mellor |
last post by:
Hi,
I hope someone can help. I have written a simple form to demonstrate
my problem/question. The code follows.
The form starts a thread, which using delegates updates a label (Every
second...
|
by: fniles |
last post by:
I am using VB.NET 2003 and a socket control. As I get quotes, I add the
quote to the arraylist, and I send the quotes to my clients by removing the
message from the arraylist and send it to the...
|
by: John A. Bailo |
last post by:
From a Windows service (NET 2.0) I want to launch serveral threads in
a for loop that invokes a method using:
new Thread(delegate()
{ myMethod(248);}).Start();
Will those threads stay...
|
by: Jon Slaughter |
last post by:
Is there any way to start a terminated thread without using a pool or
creating a new thread object?
void counter()
{
clicks = 0;
clock.Start();
while (counterActive)
{
clicks++;
|
by: sophie_newbie |
last post by:
Hi, I'm trying to write a piece of code that spawns a thread and
prints dots every half second until the thread spawned is finished.
Code is
something like this:
import threading
class...
|
by: =?Utf-8?B?QU1lcmNlcg==?= |
last post by:
Sorry this is so long winded, but here goes. Following the model of
http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.channels.ipc.ipcchannel.aspx
I made a remote object using the...
|
by: =?Utf-8?B?anAybXNmdA==?= |
last post by:
I've got a routine that builds a table using different queries, different SQL
Tables, and adding custom fields.
It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the
table...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |