Click here to Skip to main content
15,909,896 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# program that can be closed by arguments Pin
Keith Barrow26-Jun-10 22:24
professionalKeith Barrow26-Jun-10 22:24 
GeneralRe: c# program that can be closed by arguments Pin
PIEBALDconsult26-Jun-10 6:36
mvePIEBALDconsult26-Jun-10 6:36 
AnswerRe: c# program that can be closed by arguments Pin
Ravi Bhavnani27-Jun-10 5:16
professionalRavi Bhavnani27-Jun-10 5:16 
QuestionAccessing other projects "user.config" file Pin
Kaare Tragethon26-Jun-10 4:32
Kaare Tragethon26-Jun-10 4:32 
AnswerRepost - Answered in QA Pin
DaveyM6926-Jun-10 6:05
professionalDaveyM6926-Jun-10 6:05 
QuestionQuery for multiple occurance in Column Pin
Nikhil Bhivgade26-Jun-10 2:30
professionalNikhil Bhivgade26-Jun-10 2:30 
AnswerRe: Query for multiple occurance in Column Pin
Pete O'Hanlon26-Jun-10 2:33
mvePete O'Hanlon26-Jun-10 2:33 
QuestionHTML Page download in C# Pin
makumazan8426-Jun-10 1:58
makumazan8426-Jun-10 1:58 
Hi, all!
Here is the problem:
I'm writting some code that gets HTML page, and then grabs it's content. The content of the page is organized in multiple pages, and navigation between them is done by clicking on the page's number below the records (For example, there are 150 records, displayed in 10 pages * 15 records/page. Therefore, the web page contains 10 hyperlinks to other pages with records). Obviously, in order to get all the information needed, I need to loop through all the pages' links, download their HTML and afterwards parse the information.
The problem is, that I can only download 2 pages from the list. For some unknown reason, my code freeses after it downloads 2 pages. The order of the pages does not matter, for example if I start from page #5, I can only get pages 5 and 6.
According to common sense and VS debugger the problem lies in the method, that downloads HTML code

public delegate byte[] getHTTPdelegate(Uri address); // this is a delegate defined as a class member, used to perform async page download
public void downloadPage(string URL)
        {
            // creating new webclient
            client = new WebClient();
            //assigning download method to a delegate
            getHTTPdelegate dl = client.DownloadData;

            // starting async download
            IAsyncResult ar = dl.BeginInvoke(new Uri(URL), null, null);
            

            while (!ar.IsCompleted)
            {
                
                Thread.Sleep(10);
            }
            // rawpage contains HTML in terms of byte[], the result of async download
            rawPage = dl.EndInvoke(ar); // this is also the line where exception occurs
        }

After downloading page #2, the application stops, and in a minute ar two throws an unhandled exception stating that operation has timed out.
Please note, that the problem is not "why isn't it working?", but "why does it work only 2 times?", when it should be downloading all the pages.
Any ideas will be highly appreciated.
GeneralRe: HTML Page download in C# Pin
harold aptroot26-Jun-10 2:24
harold aptroot26-Jun-10 2:24 
GeneralRe: HTML Page download in C# [modified] Pin
makumazan8426-Jun-10 3:48
makumazan8426-Jun-10 3:48 
QuestionProblem on XMLUnSerialize Pin
Tiago Conceição26-Jun-10 1:33
Tiago Conceição26-Jun-10 1:33 
QuestionJoin RTF Pin
Sebastian T Xavier25-Jun-10 19:21
Sebastian T Xavier25-Jun-10 19:21 
AnswerRe: Join RTF Pin
Abhinav S25-Jun-10 22:19
Abhinav S25-Jun-10 22:19 
GeneralRe: Join RTF Pin
Sebastian T Xavier27-Jun-10 18:41
Sebastian T Xavier27-Jun-10 18:41 
AnswerRe: Join RTF Pin
Xmen Real 26-Jun-10 4:32
professional Xmen Real 26-Jun-10 4:32 
QuestionPopulate a Table with Recordset [modified] Pin
ASPnoob25-Jun-10 18:44
ASPnoob25-Jun-10 18:44 
AnswerRe: Populate a Table with Recordset Pin
Roger Wright25-Jun-10 19:32
professionalRoger Wright25-Jun-10 19:32 
AnswerRe: Populate a Table with Recordset Pin
Richard MacCutchan25-Jun-10 22:23
mveRichard MacCutchan25-Jun-10 22:23 
GeneralRe: Populate a Table with Recordset Pin
Pete O'Hanlon26-Jun-10 2:28
mvePete O'Hanlon26-Jun-10 2:28 
GeneralRe: Populate a Table with Recordset Pin
Richard MacCutchan26-Jun-10 2:59
mveRichard MacCutchan26-Jun-10 2:59 
Questioni need a very simple chat application Pin
Nikhil Bhivgade25-Jun-10 2:27
professionalNikhil Bhivgade25-Jun-10 2:27 
AnswerRe: i need a very simple chat application Pin
OriginalGriff25-Jun-10 2:46
mveOriginalGriff25-Jun-10 2:46 
GeneralRe: i need a very simple chat application Pin
Luc Pattyn25-Jun-10 3:12
sitebuilderLuc Pattyn25-Jun-10 3:12 
GeneralRe: i need a very simple chat application Pin
OriginalGriff25-Jun-10 3:18
mveOriginalGriff25-Jun-10 3:18 
GeneralRe: i need a very simple chat application Pin
Luc Pattyn25-Jun-10 3:37
sitebuilderLuc Pattyn25-Jun-10 3:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.