473,725 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTP-Download (Multithreading )

Hello,

at the moment I'm not able to finish my program. That means, I have a
problem I can't solve myself. Therefore I'm asking those who already
worked with HttpWebRequest. .. and threads.

I'm writing some kind of download-manager, which is able to download
several files parallely. Therefore I've created a class implementing the
download function and use four threads which use four instances of the
class. This works fine, except the cancelling of downloads. After a
download-thread has been cancelled, it is not able to download any files
with this thread.

How the program works:
The source for the downloadclass I got from the .net-Documentation and
enhanced in some points.
The download form has arrays for the class-instances, boolvalues
(instance busy or not) and threads (calling StartDownload-function of
classes).
A timer (timWatchTimer) cares for the single threads. If a thread is not
busy anymore (boolvalue bThreadWorking) the next download is started for
this thread (StartNextDownl oad).

I removed all unnecessary code for a better overview. The sample project
can be found at:
http://vbtricks.vb.funpic.de/vbarchiv/dstest.zip.
The sample has been written using SharpDevelop, but in the subfolder VS
you find a VS-export of the project. The source does have comments but
if there any questions, please don't hesitate to ask them. I'm really up
to solve this problem as I want to finish my program.
Please help me,

Stefan
--
_______________ _______________ _____www.VBTric ks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_______________ _______________ _______________ ________
Nov 21 '05 #1
4 1737
Hi,

If you are using windows xp bits might be best way to go.

http://msdn.microsoft.com/library/de...un02282003.asp

Ken
---------------
"VBTricks.d e.vu Webmaster" <no****@thisser verdoesntexist. com> wrote in
message news:uW******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

at the moment I'm not able to finish my program. That means, I have a
problem I can't solve myself. Therefore I'm asking those who already
worked with HttpWebRequest. .. and threads.

I'm writing some kind of download-manager, which is able to download
several files parallely. Therefore I've created a class implementing the
download function and use four threads which use four instances of the
class. This works fine, except the cancelling of downloads. After a
download-thread has been cancelled, it is not able to download any files
with this thread.

How the program works:
The source for the downloadclass I got from the .net-Documentation and
enhanced in some points.
The download form has arrays for the class-instances, boolvalues
(instance busy or not) and threads (calling StartDownload-function of
classes).
A timer (timWatchTimer) cares for the single threads. If a thread is not
busy anymore (boolvalue bThreadWorking) the next download is started for
this thread (StartNextDownl oad).

I removed all unnecessary code for a better overview. The sample project
can be found at:
http://vbtricks.vb.funpic.de/vbarchiv/dstest.zip.
The sample has been written using SharpDevelop, but in the subfolder VS
you find a VS-export of the project. The source does have comments but
if there any questions, please don't hesitate to ask them. I'm really up
to solve this problem as I want to finish my program.
Please help me,

Stefan
--
_______________ _______________ _____www.VBTric ks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_______________ _______________ _______________ ________
Nov 21 '05 #2
I wonder if you shouldnt read the data sent from the web server before
closing down the connection. Like this I guess:

Dim asynchronousInp utRead As IAsyncResult = _
responseStream. BeginRead(myReq uestState.Buffe rRead, _
0, 1024, _
New AsyncCallback(A ddressOf ReadCallBack), _
myRequestState)
' Now try and close
FinishedProc(St atusCodes.iErro rOccurred, _
ErrorCodes.iUse rCancelled)
"VBTricks.d e.vu Webmaster" <no****@thisser verdoesntexist. com> skrev i
melding news:uW******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

at the moment I'm not able to finish my program. That means, I have a
problem I can't solve myself. Therefore I'm asking those who already
worked with HttpWebRequest. .. and threads.

I'm writing some kind of download-manager, which is able to download
several files parallely. Therefore I've created a class implementing the
download function and use four threads which use four instances of the
class. This works fine, except the cancelling of downloads. After a
download-thread has been cancelled, it is not able to download any files
with this thread.

How the program works:
The source for the downloadclass I got from the .net-Documentation and
enhanced in some points.
The download form has arrays for the class-instances, boolvalues (instance
busy or not) and threads (calling StartDownload-function of classes).
A timer (timWatchTimer) cares for the single threads. If a thread is not
busy anymore (boolvalue bThreadWorking) the next download is started for
this thread (StartNextDownl oad).

I removed all unnecessary code for a better overview. The sample project
can be found at:
http://vbtricks.vb.funpic.de/vbarchiv/dstest.zip.
The sample has been written using SharpDevelop, but in the subfolder VS
you find a VS-export of the project. The source does have comments but if
there any questions, please don't hesitate to ask them. I'm really up to
solve this problem as I want to finish my program.
Please help me,

Stefan
--
_______________ _______________ _____www.VBTric ks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_______________ _______________ _______________ ________


Nov 21 '05 #3
On 2005-07-07, VBTricks.de.vu Webmaster <no****@thisser verdoesntexist. com> wrote:
Hello,

at the moment I'm not able to finish my program. That means, I have a
problem I can't solve myself. Therefore I'm asking those who already
worked with HttpWebRequest. .. and threads.

I'm writing some kind of download-manager, which is able to download
several files parallely. Therefore I've created a class implementing the
download function and use four threads which use four instances of the
class. This works fine, except the cancelling of downloads. After a
download-thread has been cancelled, it is not able to download any files
with this thread.

How the program works:
The source for the downloadclass I got from the .net-Documentation and
enhanced in some points.
The download form has arrays for the class-instances, boolvalues
(instance busy or not) and threads (calling StartDownload-function of
classes).
A timer (timWatchTimer) cares for the single threads. If a thread is not
busy anymore (boolvalue bThreadWorking) the next download is started for
this thread (StartNextDownl oad).

I removed all unnecessary code for a better overview. The sample project
can be found at:
http://vbtricks.vb.funpic.de/vbarchiv/dstest.zip.
The sample has been written using SharpDevelop, but in the subfolder VS
you find a VS-export of the project. The source does have comments but
if there any questions, please don't hesitate to ask them. I'm really up
to solve this problem as I want to finish my program.
Please help me,

Stefan


If your on a 2K or higher system and don't need to support 9x, then I
agree with Ken - use BITS. If you don't like the wrapper in the article
he pointed out, I have one that I wrote in C# ages ago :) And, yes, the
library does work with VB.NET. In fact, when I wrote it - I wrote the
wrapper in C#, but wrote the test app in VB.NET to make sure it would
work...
Anyway, as for the threads... I haven't really looked at the code so
I'm not sure what your doing here. I just wanted to interject my support
of BITS :) I have downloaded the project, and if I get a moment, I'll
see if I can see anything that strikes me as out of place :)

--
Tom Shelton [MVP]
Nov 21 '05 #4
Hello,

sorry for replying that late. The problem could be fixed by ensuring
that the response-stream has been closed when the download is cancelled.
Stefan

--
_______________ _______________ _____www.VBTric ks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_______________ _______________ _______________ ________
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
9286
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. # No warranty express or implied for the accuracy, fitness to purpose
8
10645
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad Request" was the original error msg now that I reinstalled iislockdown and urscan I get "The parameter is incorrect." If I use the get method with this form it works just fine on everything. I can't say for certain but I think this problem started...
3
5402
by: ashesdesign | last post by:
Hi All, I am very new to php and even newer to XML. Can anyone please shed some light on how to post XML requests via HTTP. I have been searching high and low and have come across many examples and snippets, but none work nor make sense to me. Below is an example of what it is I need to send as a request and the typical example I should receive. I just don't know how to send the request!!! A Request
5
10398
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said they need to consume this web service using HTTP. The developer's IDE is Notepad. Yeah, weird I know. How is this done? I guess if I can get it to run ASP, IDE independant, that should make them happy. Any references you can point me to?
4
2477
by: Bob Badger | last post by:
Hi, Simple question (although I guess with a complicated answer). Is HTTP an async protocol? For instance, if I send a message to a c# webservice via http what is the protocol actually doing? Thanks in advance Steffan
1
4289
by: zpinhead | last post by:
I am unable to get my downloaded extension from pecl to link up with php properly. seems like the php.so I could not use pear install http. pear claimed the extension was already installed. that is certainly not true. I downloaded the http extension from pecl. cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/http
3
2149
by: webEater | last post by:
Hey, I am writing a file that reads in an external file in the web and prints it out including the response header of the http protocol. I do this to enable cross domain XMLHttpRequests. I implemented it via fsockopen, like this: <? $url = $_REQUEST; // take the param as $uri //... more ...
1
1945
by: rpjd | last post by:
I am completely new to this so please bear with me here. My project involves a webpage executing php scripts via an xmlhttprequest which queries a database and returns data to the webpage. This code below is working to a degree in IE7. As I have not yet parsed http.responseText, I am getting all the code in parts.php in the alert. My php script query creates two php arrays, one a single array and a two-dimensional array such as array. My...
1
2256
by: rpjd | last post by:
I am having a problem getting the http.status of an xmlhttprequest. The request readystate has come back as readystate 4, but then it stops without confirming the http.status. Any help appreciated. <script type="text/javascript" > var postring = "?"; function string() { var first = document.numbers.first.value; var second = document.numbers.second.value; var third = document.numbers.third.value;
16
2323
by: Harry Simpson | last post by:
I've been away from ASPNET - I open up a new Web app in VS2008 and go into properties and select to use IIS instead of the personal web server. Then I run in debug mode and it says I have to set the Debug= True in the Web.config which I do. Then try to run it again and it says I must enable integrated security which I do. I then try to run it again and get the HTTP 403 error - " This error (HTTP 403 Forbidden) means that Internet...
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.