|
I have a situation where I need to download multiple files in a vb.net application.
To speed up the process, I am trying to download multiple files at one time looping through each of the files and launching them in their own thread (code below). The problem is that when there are hundreds of files to download, it launches them all at the same time and half don’t get downloaded. Any idea how I could control it to launch say 4 at a time, so that when one finished another would launch until the batch is complete? Was thinking message queues but am not sure if this is the right path to take.
Any help is appreciated
Dim count As Integer
'loop through each file
For count = CType(txturlcountbegin.Text, Integer) To CType(txturlcountend.Text, Integer)
' create new download object
Dim c As Common = New Common
' Hoook up the on download complete event
AddHandler c.FileDownloaded, AddressOf filesaved
'Set the file download properties
c.fn = txtFileName.Text
c.sp = txtSavePath.Text
c.wc = txtWildCard.Text
c.tb = txtBegin.Text
c.te = txtEnd.Text
c.url = Regex.Replace(txtURL.Text, txtURLWILDCARD.Text, count.ToString)
c.batchnum = count
'launch a new thread to download the files
Dim t As New Thread(New ThreadStart(AddressOf c.getFiles))
t.Start()
Next
|
|
|
|
|
You would have to write your own thread manager, probably using the thread pool to do this. For an example, you might want to search the 'Net for examples of download managers.
You might also want to consider using the BITS service to handle file downloads for you. For an example of this, you can check out Background Copying[^] on MSDN.
Considering that the network pipe can only send a single packet at a time to a single thread, all of your threads will be waiting for each other to get done with the network pipe. You could have 10 downloads going at the same time, but their really not going to get there much faster than if you downloaded them one at a time.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to display a save dialog box on a web page.
I used response.append header but that displays both save and open dialog whereas I want to have only the save button.
Or else. is it possible to display a file dialog box to the user the same as used in Visual Basic 6.0
Thanks in anticipation.
Regards
Nidhi
|
|
|
|
|
This question really belongs in the ASP.NET Forum. But, you really don't have any control over the dialog box the browser puts up in response to downloading a file. Unless, of course, your page has the dialog box functionality coded in JavaScript.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
can u code the same in java scrpit?if yes how.
thanks n regards
|
|
|
|
|
Like I said, this is a question for the ASP.NET Forum, not VB.NET.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I wanted to show a PrintPreviewDialog directly on top of a form in my application just like the way IE does. However, setting the Location, Size and the SetDesktopLocation properties of the dialog fails to do this. The dialog has the same size as the calling form does but it is moved to the left and lower than the calling form. I think this is by design but I do not know why. Is there a workaround for this?
|
|
|
|
|
Can it be determined if the user presses a menu or if the user uses a shortcut? Both actions result in the same code being run, I just wanted a slightly different behavior between the ShortCut and the Menu.
|
|
|
|
|
That doesn't follow proper GUI standards at all. If the user presses a keyboard shortcut for a menu item, it should do EXACTLY the same thing as clicking on that menu item.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, I know. But could it be done?
|
|
|
|
|
There is nothing in the MenuItem event handlers that will expose this kind of information. You could try to use the OnKeyDown and OnKeyUp events to track what keys are being used just before the Click event fires on the MenuItem object, but I don't see this as a good or even flexible option to use. Is that much code really worth the odd (and non-intuitive) interface?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can i interrupt a loop operation? Example im iterating over all the records of a 100,000 datareader however i decided to cut short the iteration by clicking a Stop button. How do i do that?
|
|
|
|
|
you can set a temp var
dim tmp as boolean
when you press the button set it to true
in the while code use this
while tmp = true
...
end while
|
|
|
|
|
You add a variable that you check within the loop. Exapmle:
<br />
dim b as boolean as boolean<br />
dim i as long <br />
for i=0 to i=1000<br />
if b=true then<br />
exit for<br />
end if<br />
next i<br />
you change the value of b somewhere else in your code, probably in the "Stop" Button event. You may also want to consider concurrency issues on that variable.
Good Luck.
|
|
|
|
|
erm.. what would the point of this be. You're saying give me the number from this list, when it's this number that I have already.
I'm not sure, but should you not put quotes around a query for a numeric value ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
ralphz wrote:
if i never include 'where TagNo= '"+ ListHardware.selecteditem.tostring+"'" ' then all field is populated
That's because you selected them all.
My advice would be to stay away from computers.
First of all, the advice I gave yesterday is correct, you should get rid of the quotes around the number you're looking for, otherwise you look for it as a string.
Secondly, the SQL as I read it yesterday was something like SELECT ID from myTbl WHERE ID=5. If you know ID is 5, why do you need to select it ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
That's because you selected them all.
My advice would be to stay away from computers
Christian, are you the kind of VB programmer that was teased/bullied at school, who now feels he must look down on others in need of help, introducing a side of snide comments and an unfriendly attitude.
|
|
|
|
|
Anonymous wrote:
Christian, are you the kind of VB programmer that was teased/bullied at school,
No, actually, I am an actual programmer ( I don't use VB, and I refuse jobs that require me to ), who comes into the VB forum on the basis that I can help people with VB.NET questions.
Anonymous wrote:
who now feels he must look down on others in need of help
I was actually trying to help.
Anonymous wrote:
introducing a side of snide comments and an unfriendly attitude.
I did feel bad about being rude to this guy afterwards, but the fact is that both myself, and everyone I have shown this code to, thinks it is hilarious. I told the guy (assuming you're a general anonymous pussy and not the guy in question ) that the query was redundant, and he still couldn't work it out. Based on that, he is clearly over his depth, and anyone who is over their depth using SQL or VB should seriously consider if they're up to the world of computers.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
well i'm trying to create a control that inherits from textbox or richtextbox to make the background gradient
i use the following code :
CODE
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim gbr As LinearGradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Me.Width, Me.Height), Color.White, Color.Blue, LinearGradientMode.Horizontal)
e.Graphics.FillRectangle(gbr, New Rectangle(0, 0, Me.Width, Me.Height))
End Sub
but this isn't working... the backcolor in both is always white.
can someone help? thanks in advance
|
|
|
|
|
|
What is the correct syntax in a .NET SQL INSERT or UPDATE command which will create a NULL in an integer field in Microsft Access?
Note: because I already do this in other parts of my code through use of datasets and "DBNull.Value", I not only know that it is possible, I can also write a cumbersome work-around using these.
But I believe that some simple way can be found to do this using "OleDbCommand(sql, connection)" and the appropriate string for "sql".
I've tried 'null', nothing, DBNull.Value and several othersin my "sql" string. All give me syntax errors as the code attempts to update the database.
Thanks, Jimbeau
|
|
|
|
|
.NET Framework Class Library
SqlInt32.Null Field
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqltypessqlint32classnulltopic.asp
|
|
|
|
|
Hi All!
Sorry for the cryptic explanation that follows!
My problem is :
i have created a gradient on a form, and then I have put a custom control that i created that just basically implements a picturebox control.
The control is a checkbox control that uses graphics that i made in photoshop, saved as a png file, which incorperates transparency.
The problem is that my control doesnt maintain transparency over this freshly
created GDI+ gradient, however if i was to put the control over a picture say in a picture box that i had loaded from file then it works!
When i do it over the GDI+ stuff, i see a (grey windows default coloured) box around my Checkbox!
If that lot makes any sense to any one i would appr. any help anyone can offer!
Thanks for your help!
|
|
|
|
|
Does anyone know how to lock the keyboard and mouse?
I have a sensitive part in my code where I do not want the user to be able to do anything with the keyboard, not just in my application - nothing at all!
Just for a few seconds I want to lock the keyboard and mouse.
Thanks,
Haim.
|
|
|
|
|
This is definately NOT a good idea! Unless your application is doing something in realtime, like high resolution data sampling, there is no good reason to do this.
But...
You'll have to write a keyboard hook and a mouse hook to "disable" them. There is no API call you can make. In VB.NET you could also just write a couple of Message Filters and add them using Application.AddMessageFilter , the docs are here[^] on MSDN. You would have to filter ALL the keyboard and mouse messages.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|