Question Help with Multithreading Please :)

ihave1245

New member
Joined
Oct 19, 2011
Messages
2
Programming Experience
5-10
Purpose: Use selected one or multiple currencies then from this, browsers open up simultaneously and auto refresh, so as to see changing currency rates


I have created an app, Which using a listbox and a button creates a copy of the set form and passes a url through to the form. Once the url had been passed through and the new form created. This new form will then using a timer refresh the page ever 2 or so seconds.


The problem I am facing is, 6/7 forms created continually refresh as intended but one of the forms does not.
From what I understand, this is due to the fact that each application is given an amount of processing speed and I have moved over the amount allocated to my prog.

I would like to when asking to make acopy of the form for this form to be opened on a new thread.

How do I do this??
Btw I really wish to use multi-threading to fix this


Public Class RefreshPage
Public AssignWeb As String
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WebBrowser1.Navigate(AssignWeb)
End Sub
End Class


Public Class Form1
Dim CurrencyUrl, NormalUrl, MyCurrency, MiddleSymbol As String
Public Sub CopyFORM(ByVal SelectedCur As String)
NormalUrl = "http://www.xe.com/ucc/convert/?Amount=1&From="
MiddleSymbol = "&To="
MyCurrency = "GBP"
CurrencyUrl = NormalUrl & MyCurrency & MiddleSymbol & SelectedCur


Dim f As RefreshPage
f = New RefreshPage
f.Name = "Currency: " & SelectedCur
f.Text = f.Name
f.AssignWeb = CurrencyUrl
f.Show()


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i As Integer

For i = 0 To ListBox1.SelectedItems.Count - 1
Call CopyFORM(ListBox1.SelectedItems(i))
Next


End Sub
End Class

thumb_YZ22XQjC57W2sE1js1HLDV7jZ.png


thumb_oiPaXiojHVW8JLPSeTyDXkBXf.png


thumb_XmqYpLnKURz0m1FG4exTlzsq7.png

Thank you in advance for all help
 
Specifically, XE doesn't permit usage like that. I see they sell a Datafeed for a starting fee of $540, so you can imagine how expensive usage is. I'm sure you can find a cheaper alternative for your needs.

Generally, perhaps you're putting too much load too frequently on the server. Updating 7 forms with a timer tick of 1 second could even a calculator do these days, but would the currency data have any significant change in such a time span? Most likely not. So what does "continually refresh" mean, 10 request per second? :frog:

About having multiple UI threads, as a theoretical question, that is just a plain bad idea. One reason is there is only one message pump. Secondly only data processing really needs to be threaded, UI thread will happily keep up as long as it is not bogged down by data processing.

To conclude, what you should be looking for is raw currency data, this can be downloaded and processed on a background thread, and after that passed to and displayed in a UI form. Though for anything updated more than one or a few times a day you'll probably only find pay services, and most such will actively detect and prevent misusage of their "free" front-ends.
 
Thank you for your input :)
But I understand the idea itself maybe flawed, getting direct data download would fix the actual idea.

Nevertheless It's really annoying me that this program won't work. The fact that one form stops whilst the others carry on to refresh. Seems to be a processing time issue, which could be solved with multithreading. Hence the reason for me asking for the VB community's help.
 
Back
Top