473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WebRequest & Async IO problems

Hello,

I'm using the WebRequest class to download a few files of a webserver. I
use
async io to fecth the data. My problem is that the first file works like a
charm, and
the second file loads about 99%. The problem is that i *know* that BeginRead
is
called for the second file (over and over again) but the callback is never
called for
the last few bytes (or the transfer complete where it returns zero bytes).

I've looked over and over again and I've made sure all the streams are
flushed and
closed for each of the files. If I download either of the files seperate
then it works
like a charm.

The code is a couple of hundred lines long so I won't paste any code, but
I'm hoping
someone things this sounds familiar and can offer some advice.

Basicly what I do it..

(1) Create a WebRequest to file
(2) Open a new filestream
(3) Call BeginRead
(4) The callback is called time after time
(5) If I recieve more then 0 bytes I write them to the file,
else I close BOTH the filestream and the response stream
(6) If I have more files to downloads I repeat from (1) else I'm done.

I can't see why things get stuck up all of a sudden.

//Andreas
Nov 16 '05 #1
1 2140
Nevermind, then problem was on the UI end...

--
ANDREAS HÅKANSSON
STUDENT OF SOFTWARE ENGINEERING
andreas (at) selfinflicted.org
"Andreas Håkansson" <andy.h (at) telia.com> wrote in message news:#I*************@TK2MSFTNGP11.phx.gbl...
Hello,

I'm using the WebRequest class to download a few files of a webserver. I
use
async io to fecth the data. My problem is that the first file works like a
charm, and
the second file loads about 99%. The problem is that i *know* that BeginRead
is
called for the second file (over and over again) but the callback is never
called for
the last few bytes (or the transfer complete where it returns zero bytes).

I've looked over and over again and I've made sure all the streams are
flushed and
closed for each of the files. If I download either of the files seperate
then it works
like a charm.

The code is a couple of hundred lines long so I won't paste any code, but
I'm hoping
someone things this sounds familiar and can offer some advice.

Basicly what I do it..

(1) Create a WebRequest to file
(2) Open a new filestream
(3) Call BeginRead
(4) The callback is called time after time
(5) If I recieve more then 0 bytes I write them to the file,
else I close BOTH the filestream and the response stream
(6) If I have more files to downloads I repeat from (1) else I'm done.

I can't see why things get stuck up all of a sudden.

//Andreas
Nov 16 '05 #2

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

Similar topics

8
by: Dave | last post by:
I'm using the BeginInvoke method of a delegate to invoke a thread asynchronously and then use the EndInvoke to retrieve the value. This works wonderfully until a Serviced Component is added to...
0
by: Pete Davis | last post by:
I have an app that needs to work with its own uri scheme. Instead of http:, I'm going to use wwkb: I will register my uri prefix to run my app, and it only needs to be available when my app is...
1
by: Ron | last post by:
Hi there, I'm trying to 'browse' a website using the HttpWebRequest class by calling the following function (webRequest is declared outside the function): private string GetHtml(string sUrl) {...
4
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
0
by: DotNetShadow | last post by:
Hi Guys I came across this article which deals with Performance Considerations for Making Web Service Calls from ASPX Pages:...
5
by: archana | last post by:
Hi all i am having application which is using asychronous web request. At a time i am processing 5 urls asynchronously. Application working properly for 5 asynchronous call. But sometimes CPU...
1
by: Demi | last post by:
I'm trying to use an Async="true" page to do an async HttpWebRequest. My code is based on the MSDN example: http://msdn2.microsoft.com/en-us/library/21k58ta7.aspx The problem I'm having is...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.