In the main workflow cycle, which I have to interrogate in order to know if it works, I let it sleep so as not to wait. How to determine a good length for sleep? E. g. if I wake up every millisecond, it is probably useless to sleep at all. If I wake up every ten minutes, this may make the application look unresponsive (depending on what the thread is doing).
I heard so far that the frame says below that the user user will not notice the time frame of about 100 ms, but what about approaching it from the machine? How small can an interval go before it starts wastefully?
I think it comes down to a more general (e.g. platform independent) version of this question .
EDIT: Of course, the question should always be rephrased first like this: "How can I change this to an event template instead of polling," but let's say that now I cannot or do not want.
Sometimes a survey is the answer .
However, how often it depends on what the thread does, so make it customizable.
, . , ( ). - , , 30 , , . MOMENT ( 5 ).
, / , . 1-5 ( , ).
, , , . , Windows, , 60 , 60 .
, Rip Van Winkle .
, , , .
,
? , ? , :
while(!workComplete) { Thread.Sleep(n); }
, - , . , 500 . , , , . , , .
. , 200 , . , 400 . , 800 . .. , TimeoutException, .
, . , Java wait/notify.
, , 100 . .
You must give a signal to warn the flow. If you use c, you can use something like a conditional variable from p-streams. If you are using something newer, such as .NET, you can use EventWaitHandle. I am sure that java and other 4gl have similar classes like EventWaitHandle.
Let him sleep forever, awakening him when there is an entrance available?
Source: https://habr.com/ru/post/1703751/More articles:DotNetNuke: social links for a blog module - moduleWhere should I implement functionality in the page object or in OnPreInit? - constructorDevelopers who have experience with .NET 3.0 or higher, what features would you recommend first? - .netnunit setup / teardown not working? - c #How can I ignore DTD validation, but retain Doctype when writing an XML file? - javaMultiple WHEN inside without CASE expressions in SQL? - sqlGetting the path to ClickOnce file association - shellRender multiline text with Rails? - ruby | fooobar.comThe SQL Server procedure returns multiple tables. Insert results into tables. - sqlSetting up Django with mod_python, Apache on SuSE with an alias - djangoAll Articles