Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Petlja -Do While Not- i -Timer- u isto vrijeme.

[es] :: Visual Basic 6 :: Petlja -Do While Not- i -Timer- u isto vrijeme.

[ Pregleda: 3921 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Petlja -Do While Not- i -Timer- u isto vrijeme.27.09.2004. u 22:35 - pre 238 meseci
Mogu li da natjeram procesor da u isto vrijeme obradjuje dvije procedure.

Objasnjenje:

Imam petlju "Do While Not" koja se vrti oko 0-3 minute dok ne izracuna zeljenu vrijednost.
E sad prije nje sam startovao Timer i podesio ga na Interval "10".
U Timer sam stavio brojac: "T = T + 1".
Iza petlje je kod da mi ispise u "Label1" Vrijednost "T" i zaustavi "Timer" .
Medjutim u ovom slucaju "Timer" uopste ne broji jer se procedura "Private Sub Timer1_Timer()"
ne izvrsava dok god ne zavrsi petlja "Do While Not", a meni je potrebno da znam tacno
vrijeme, u mS, koliko se dugo izvrsavala ova procedura.

Ako neko zna rjesenje ili na slican ili na neki potpuno drugi nacin bio bi zahvalan.
 
Odgovor na temu

Marko_L
Beograd

Član broj: 20532
Poruke: 2885
*.yubc.net

Jabber: Marko_L@elitesecurity.org


+828 Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.27.09.2004. u 22:55 - pre 238 meseci
Uopšte ne moraju da se izvršavaju dve procedure u isto vreme.Možeš da iskoristiš sistemsko vreme pri računanju.Probaj ovako, pre nego započneš petlju, stavi
Code:
vreme = Time

a onda, po završetku petlje:
Code:
proteklo = DateDiff("s", vreme, Time) * 1000

I dobićeš vreme u milisekundama.
-Odracuonogakomijedrpiorazmaknicu.
-Ne rxdi mi txstxturx, kxd god hocu dx
ukucxm "x" onx ukucx "x".
-Ko kaaz e da ja neuummem da kuuca
m.
-Piše "Insert disk 3", a jedva sam i ova
dva ugurao u drajv
-Postoje samo dve osobe kojima
verujem, jedna sam ja, a druga nisi ti
 
Odgovor na temu

Vranac
Vranac Srdjan
Software developer
Novi Sad, Vojvodina

Član broj: 3493
Poruke: 353
*.panline.net

Jabber: vranac@elitesecurity.org
ICQ: 64150005
Sajt: www.linkedin.com/in/vrana..


+1 Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 05:15 - pre 238 meseci
stavi u petlju DoEvents().

Yields execution so that the operating system can process other events.

Syntax

DoEvents( )

Remarks

The DoEvents function returns anInteger representing the number of open forms in stand-alone versions of Visual Basic, such as Visual Basic, Professional Edition. DoEvents returns zero in all other applications.

DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.

DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file. For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.. In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.

Caution Any time you temporarily yield the processor within an event procedure, make sure theprocedure is not executed again from a different part of your code before the first call returns; this could cause unpredictable results. In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.

Idle mind is the devils playground, in my case it turned out to be an amusement park.

Sustina problema ove zemlje:
Legeonar_: Sto pre treba da shvatite da je EU propast i da se tamo mora raditi,a ne samo biti zaposlen.
http://www.elitemadzone.org/p1864861

Nobody Remains Virgin, Life Fucks Everyone
 
Odgovor na temu

mladenovicz
Zeljko Mladenovic
Xoran Technologies, Inc., Ann Arbor, MI,
USA / Software Engineer
Ann Arbor, MI, USA

Član broj: 6598
Poruke: 2065
*.bg.wifi.vline.verat.net

Jabber: mladenovicz@elitesecurity.org
ICQ: 95144142
Sajt: yubc.net/~mz


Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 10:05 - pre 238 meseci
Citat:
MSDN:
The GetTickCount function retrieves the number of milliseconds that have elapsed since Windows was started.


Code:

Private Declare Function GetTickCount& Lib "kernel32" ()

Private Sub Form_Load()
    Dim Duration    As Long
    Dim i           As Long
    
    Duration = GetTickCount()
    For i = 1 To 10000
        Debug.Print i
    Next
      
    Debug.Print "Finished in " & GetTickCount - Duration & " ms"
End Sub

 
Odgovor na temu

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 17:38 - pre 238 meseci
OK Hvala svima.

A dali je moguce da se ogranici zauzece procesora, posto dok se vrti u petlji ono je
100%? Znaci jel moguce da ogranicim procesor na npr. 50% zauzeca, dok se vrti u
petlji "Do While Not"???
 
Odgovor na temu

VRKY

Član broj: 21087
Poruke: 4690
*.net.htnet.hr



+8 Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 18:28 - pre 238 meseci
Mislim da se ne može...
Processor se drži na 100% dok ne odradi ovo (bar ja msilm) pa smanji taj broj (ako ti to tvoja aplikacija dopušta)

Code:

For i = 1 To 10000
        Debug.Print i
Next

P:S nisam čitao sve postove.. pa ne znam o čemu se točno radi..
 
Odgovor na temu

mladenovicz
Zeljko Mladenovic
Xoran Technologies, Inc., Ann Arbor, MI,
USA / Software Engineer
Ann Arbor, MI, USA

Član broj: 6598
Poruke: 2065
*.bg.wifi.vline.verat.net

Jabber: mladenovicz@elitesecurity.org
ICQ: 95144142
Sajt: yubc.net/~mz


Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 19:43 - pre 238 meseci
Mozda nesto moze da se napravi sa prioritetima, ali nisam siguran. Ako si dokon, probaj ;)

Code:

Const THREAD_BASE_PRIORITY_IDLE = -15
Const THREAD_BASE_PRIORITY_LOWRT = 15
Const THREAD_BASE_PRIORITY_MIN = -2
Const THREAD_BASE_PRIORITY_MAX = 2
Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
Const THREAD_PRIORITY_NORMAL = 0
Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
Const HIGH_PRIORITY_CLASS = &H80
Const IDLE_PRIORITY_CLASS = &H40
Const NORMAL_PRIORITY_CLASS = &H20
Const REALTIME_PRIORITY_CLASS = &H100
Private Declare Function SetThreadPriority Lib "kernel32" _
(ByVal hThread As Long, ByVal nPriority As Long) As Long
Private Declare Function SetPriorityClass Lib "kernel32" _
(ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Private Declare Function GetThreadPriority Lib "kernel32" _
(ByVal hThread As Long) As Long
Private Declare Function GetPriorityClass Lib "kernel32" _
(ByVal hProcess As Long) As Long
Private Declare Function GetCurrentThread Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Sub Form_Load()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Dim hThread As Long, hProcess As Long
    'retrieve the current thread and process
    hThread = GetCurrentThread
    hProcess = GetCurrentProcess
    'set the new thread priority to "lowest"
    SetThreadPriority hThread, THREAD_PRIORITY_LOWEST
    'set the new priority class to "idle"
    SetPriorityClass hProcess, IDLE_PRIORITY_CLASS
    'print some results
    Me.AutoRedraw = True
    Me.Print "Current Thread Priority:" + Str$(GetThreadPriority(hThread))
    Me.Print "Current Priority Class:" + Str$(GetPriorityClass(hProcess))
End Sub



Citat:
Parameters:
· hProcess
Identifies the process.
Windows NT: The handle must have the PROCESS_SET_INFORMATION access right. For more information, see Process Objects.

· dwPriorityClass
Specifies the priority class for the process. Specify one of the following values:
HIGH_PRIORITY_CLASS
Specify this class for a process that performs time-critical tasks that must be executed immediately. The threads of the process preempt the threads of normal or idle priority class processes. An example is Windows Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class application can use nearly all available CPU time.
IDLE_PRIORITY_CLASS
Specify this class for a process whose threads run only when the system is idle. The threads of the process are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle-priority class is inherited by child processes.
NORMAL_PRIORITY_CLASS
Specify this class for a process with no special scheduling needs.
REALTIME_PRIORITY_CLASS
Specify this class for a process that has the highest possible priority. The threads of the process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive.

 
Odgovor na temu

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.28.09.2004. u 21:33 - pre 238 meseci
Citat:
VRKY: Mislim da se ne može...
Processor se drži na 100% dok ne odradi ovo (bar ja msilm) pa smanji taj broj (ako ti to tvoja aplikacija dopušta)

Ne mogu da smanjim broj Objasnicu o cemu se radi...
Citat:
mladenovicz: Mozda nesto moze da se napravi sa prioritetima, ali nisam siguran. Ako si dokon, probaj ;)

Prejednostavan je ovo program da bi ga toliko komplikovao.

Evo o cemu se radi: Na formi je 1 TextBox, 1 CommandButton i 1 Label.U TextBox Upisete neki cijeli broj u TextBox
i pritiskom na dugme program treba da u Label ispise prvi sledeci, cijeli, PROSTI broj. Ako neko ne zna:
>>Broj je PROST ako nije djeljiv ni sa jednim cijelim brojem osim sa 1 i sa samim sobom<<
Ja i kolega se takmicimo ko ce da napravi brzi program za izracunavanje. To je inace zadatak sa
nekog faksa. Ako je neko dokon da vjezba, evo lijepog zadatka. Zakacio sam moj program uz ovu
poruku. Ako neko uspije da napravi brze Neka javi.
Pomoc:
Broj X je prost ako nije djeljiv sa prvih X/2 Brojeva. Znaci Ostale ne morate provjeravati.
Ja sam program ogranicio na 9 cifara.
Nije tako jednostavno kao sto Izgleda!!!
Prikačeni fajlovi
 
Odgovor na temu

mladenovicz
Zeljko Mladenovic
Xoran Technologies, Inc., Ann Arbor, MI,
USA / Software Engineer
Ann Arbor, MI, USA

Član broj: 6598
Poruke: 2065
*.bg.wifi.vline.verat.net

Jabber: mladenovicz@elitesecurity.org
ICQ: 95144142
Sajt: yubc.net/~mz


Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.29.09.2004. u 10:11 - pre 238 meseci
1. Deljivost sa 2 bi trebalo brze da se ispituje ovako:
Code:

If (MyNumber And 1) = 0 Then ' nije paran


2.
Citat:

Broj X je prost ako nije djeljiv sa prvih X/2 Brojeva


ako se dobro secam, dovoljno je proveravati samo prvih Sqr(X) brojeva
 
Odgovor na temu

Ero S Ovoga Sveta

Član broj: 21509
Poruke: 173
*.teol.net



Profil

icon Re: Petlja -Do While Not- i -Timer- u isto vrijeme.30.09.2004. u 01:45 - pre 238 meseci
Citat:
mladenovicz

ako se dobro secam, dovoljno je proveravati samo prvih Sqr(X) brojeva

Upravu si.

Sa petlje Do While Not presao sam na petlju For Next Step 2 i promvjeravam samo
neparne brojeve, cime se duplo ubrza.
 
Odgovor na temu

[es] :: Visual Basic 6 :: Petlja -Do While Not- i -Timer- u isto vrijeme.

[ Pregleda: 3921 | Odgovora: 9 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.