|
-
Aug 26th, 2012, 04:52 PM
#1
Thread Starter
Addicted Member
Last edited by jalexander; Aug 28th, 2012 at 10:24 PM.
Reason: [RESOLVED] 8/28/2012
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Aug 26th, 2012, 06:05 PM
#2
Re: need help: Adding a pause to my webpage parse function
The easiest all purpose delay is ..
vb.net Code:
Dim t As UInt64 = Now.Ticks
Do Until Now.Ticks - t >= d * 10 ^ 7 'where d is required delay in seconds
Loop
-
Aug 27th, 2012, 03:44 PM
#3
Thread Starter
Addicted Member
Re: need help: Adding a pause to my webpage parse function
Awesome thank you very much...
Now i guess...
Can anyone give me an idea of how/where to implement this pause? (i.e. inside the function, in the background worker itself, etc.)
I'm at a total loss where to get started
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Aug 27th, 2012, 04:32 PM
#4
Re: need help: Adding a pause to my webpage parse function
Well if the goal is to pause between reading pages from the server the only place to put it would appear to be immediately after ....
ProgressBar1.Value = i
... in the Parse sub. As a word of warning though, I should tell you that 20 seconds is an eternity in computing terms, and if a pause is necessary at all then 2-5 seconds is more than adequate for most purposes, especially if you're just spinning the wheels as it were.
-
Aug 27th, 2012, 08:18 PM
#5
Thread Starter
Addicted Member
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by dunfiddlin
Well if the goal is to pause between reading pages from the server the only place to put it would appear to be immediately after ....
ProgressBar1.Value = i
... in the Parse sub. As a word of warning though, I should tell you that 20 seconds is an eternity in computing terms, and if a pause is necessary at all then 2-5 seconds is more than adequate for most purposes, especially if you're just spinning the wheels as it were.
The goal is to add a pause between 'each request' for a page from the web server. So if that's what you meant then ok, I will make sure to make it around 5 seconds then!
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Aug 27th, 2012, 08:26 PM
#6
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by dunfiddlin
The easiest all purpose delay is ..
vb.net Code:
Dim t As UInt64 = Now.Ticks
Do Until Now.Ticks - t >= d * 10 ^ 7 'where d is required delay in seconds
Loop
This is a more compact equivalent:-
vbnet Code:
Threading.Thread.Sleep(d * 1000)
-
Aug 28th, 2012, 07:31 AM
#7
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by Niya
This is a more compact equivalent:-
vbnet Code:
Threading.Thread.Sleep(d * 1000)
You can't use Thread.Sleep in a background worker (or at least you couldn't last time I looked into it ... I doubt that it's changed, however).
-
Aug 28th, 2012, 12:46 PM
#8
Thread Starter
Addicted Member
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by dunfiddlin
You can't use Thread.Sleep in a background worker (or at least you couldn't last time I looked into it ... I doubt that it's changed, however).
Ok so what does the 10 & 7 equal out to be in..... Do Until Now.Ticks - t >= d * 10 ^ 7
I'm not familiar with that structure...I'm used to writing out seconds in timers like 75000 = 75 seconds
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Aug 28th, 2012, 12:53 PM
#9
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by jalexander
Ok so what does the 10 & 7 equal out to be in..... Do Until Now.Ticks - t >= d * 10 ^ 7
I'm not familiar with that structure...I'm used to writing out seconds in timers like 75000 = 75 seconds
10 to the power of 7 (or 10,000,000 to you) ticks per second.
-
Aug 28th, 2012, 07:42 PM
#10
Thread Starter
Addicted Member
Last edited by jalexander; Aug 28th, 2012 at 10:25 PM.
Reason: duplicate post
-
Aug 28th, 2012, 09:26 PM
#11
Thread Starter
Addicted Member
Re: need help: Adding a pause to my webpage parse function
Worked perfectly! Thank you so much @dunfiddlin ! You just solved a problem I've had now for months...this is why I love this forum & all the awesome people on here <3 <3 love love love you all!
1 - question though .... so 'd' = number of seconds to pause right...do I write 5 seconds as '5' or as '5000' (as within a timer). Btw thanks also for '20' seconds is a life-time in computing tip I'll keep that in mind because when I thought about it...it made a lot of sense! <3
& thanks also to @Niya for the compact version!
You guys are seriously the best. When I start college this fall I'll have all of you to thank...for being so far ahead of everyone else in the 101 course! <3
Last edited by jalexander; Sep 2nd, 2012 at 12:12 AM.
Reason: [RESOLVED]
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Aug 29th, 2012, 05:15 AM
#12
Re: need help: Adding a pause to my webpage parse function
Last edited by Niya; Aug 29th, 2012 at 05:19 AM.
Reason: Double post
-
Aug 29th, 2012, 05:17 AM
#13
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by dunfiddlin
You can't use Thread.Sleep in a background worker (or at least you couldn't last time I looked into it ... I doubt that it's changed, however).
This is not true. Thread.Sleep can pause any thread.
-
Aug 29th, 2012, 08:04 AM
#14
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by Niya
This is not true. Thread.Sleep can pause any thread.
Well, no it can't. It can't pause the background worker because that isn't a thread within the strict definition of the relevant namespace. Many have tried. All have failed.
Last edited by dunfiddlin; Aug 29th, 2012 at 11:31 AM.
-
Aug 29th, 2012, 08:06 AM
#15
Re: [RESOLVED] Adding a pause to my webpage parse function
-
Sep 1st, 2012, 10:18 PM
#16
Re: need help: Adding a pause to my webpage parse function
 Originally Posted by dunfiddlin
Well, no it can't. It can't pause the background worker because that isn't a thread within the strict definition of the relevant namespace. Many have tried. All have failed.
And I'm telling you that you're wrong. See for yourself:-
vbnet Code:
'
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For i = 1 To 1000
Threading.Thread.Sleep(100)
SetLabelText(i)
Next
End Sub
Private Sub SetLabelText(ByVal text As String)
If Label1.InvokeRequired Then
Label1.Invoke(New Action(Of String)(AddressOf SetLabelText), text)
Else
Label1.Text = text
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
Start a new project and place the above code in Form1 along with a Label, Button and a BackgroundWorker. Run the program and press the button.
-
Sep 2nd, 2012, 04:23 PM
#17
Thread Starter
Addicted Member
Re: need help: Adding a pause to my webpage parse function
I'm curious...you said I could use the following
Code:
Threading.Thread.Sleep(d * 1000)
i.e. to pause for 5 seconds i would use...
Code:
Threading.Thread.Sleep(5 * 1000)
but in the code above you used...
Code:
Threading.Thread.Sleep(100)
does that mean i could simply put in my code...
Code:
Threading.Thread.Sleep(5000)
To pause for 5 seconds?
Also, can this code be used anywhere in a sub, or does it need to be in specific places....like right before the end of a sub etc. Or does it all depend?
Thanks
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Sep 2nd, 2012, 10:41 PM
#18
Re: [RESOLVED] Adding a pause to my webpage parse function
It can be used anywhere. And yes you can use 5000 directly.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|