|
-
Apr 11th, 2013, 09:16 AM
#1
Thread Starter
Addicted Member
How can i do that without using timer and much faster add google results into listbox
Hi,i need some help using listbox and pull out urls from google search results and put into listbox faster with no timer if it's possible to do that
without waiting timer to finish.
Here are some examples what i want to change.
This is using with timer.
Using timer it is becoming very slow and need to wait while timer to finish and it is very silly.
I have crossed out all over google pages results but i haven't find the answer to that question until.
This is what i need just to change something in my code but i do not know exactly how i can do that without using timer.
I know that it is possible to do but the question is how ?
Code:
dim i as integer = 0
i = i + 10
Dim wc As New WebClient
Dim source As String = wc.DownloadString("http://www.google.com/search?q=" & TextBox1.Text & "&start=" & i)
Dim m1 As MatchCollection = Regex.Matches(source, "", RegexOptions.Singleline + RegexOptions.IgnoreCase)
For Each m As Match In m1
Dim value As String = m.Groups(0).Value
If Not m.Value.Contains(".png") And Not m.Value.Contains(".gif") And Not m.Value.Contains(".jpg") And Not m.Value.Contains("google") Or
m.Value.Contains("free") Or m.Value.Contains("freeware") Then
ListBox1.Items.Add(m.Groups(0).ToString())
End If
Next
-
Apr 11th, 2013, 09:47 AM
#2
Re: How can i do that without using timer and much faster add google results into lis
How is that using a timer?
My usual boring signature: Nothing
 
-
Apr 11th, 2013, 11:25 AM
#3
Re: How can i do that without using timer and much faster add google results into lis
Why would you use a timer any way? The only scenario i can imagine is you dont no about raising events to notify the download has completed. Loop the method using Async method of webclient thats on a threaded pool and let VB handle the rest.
-
Apr 12th, 2013, 05:15 AM
#4
Thread Starter
Addicted Member
Re: How can i do that without using timer and much faster add google results into lis
Of course I do not know how to use the raising events or how you say there.
Why do I use the timer ?
I use a timer just because I do not know how else to change and make it work faster without using timer.
I need to adapt this code if it is possible.Need a bit of examples.
-
Apr 12th, 2013, 06:48 AM
#5
Re: How can i do that without using timer and much faster add google results into lis
I dont have time to edit it. Here is an example i wrote that you should easily be able to adapt to your needs.
vb Code:
Imports System.Net Public Class MainForm Private ReadOnly temp As String = "http://download.piriform.com/ccsetup327.exe" Private m_dictionary As New Dictionary(Of WebClient, ListViewItem) Private Sub Download(ByVal Path As String, ByVal FileName As String) Dim client As New WebClient AddHandler client.DownloadProgressChanged, AddressOf DownloadProgressChanged AddHandler client.DownloadFileCompleted, AddressOf DownloadFileCompleted Dim lvw As New ListViewItem With {.Text = FileName} lvw.SubItems.Add("0%") Me.FileDownLoadListView.Items.Add(lvw) client.DownloadFileAsync(New Uri(temp), Path & Filename) Me.m_dictionary.Add(client, lvw) End Sub Private Sub DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) m_dictionary.Item(CType(sender, WebClient)).SubItems(1).Text = e.ProgressPercentage & "%" End Sub Private Sub DownloadFileCompleted(ByVal sender As Object, _ ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Dim client As WebClient = DirectCast(sender, WebClient) client.Dispose() m_dictionary.Remove(client) Debug.WriteLine(m_dictionary.Count) End Sub Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click For i As Integer = 0 To 5 Download("C:\Temp\", String.Format("FileName{0}.exe", i)) Next End Sub End Class
Just take not the for loop. Handling of the completed event. You may choose to ignore the progress changed event. Always consult MSDN first when issues arise.
-
Apr 12th, 2013, 09:30 AM
#6
Re: How can i do that without using timer and much faster add google results into lis
What ident showed does seem like a better way to go, but I'm still struck by the fact that you insist that you are using a timer, yet didn't show any code that uses a timer.
My usual boring signature: Nothing
 
-
Apr 13th, 2013, 04:08 AM
#7
Thread Starter
Addicted Member
Re: How can i do that without using timer and much faster add google results into lis
I need normal example not like this i do not see point using it cuz i do not see good code here.
This is not code what i need.
according to your samples do not meet code, which just offers.
This is more similar to the downloader.
I need more samples
-
Apr 14th, 2013, 03:47 AM
#8
Thread Starter
Addicted Member
Re: How can i do that without using timer and much faster add google results into lis
Never mind i have found the answer
-
May 11th, 2013, 02:54 AM
#9
Thread Starter
Addicted Member
Re: How can i do that without using timer and much faster add google results into lis
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
|