Simple web fetching class with: string Get(string URL), bool Busy and Stop() members

  • Thread starter Thread starter x.meglio
  • Start date Start date
X

x.meglio

I'm looking for simple class to get web-page with some members to
control execution:
1. string Get(string URL) - just get html-page
2. bool Busy - return true while object loading resource
3. Stop() to stop execution

There are problems to use HTTPWebRequest.GetResponse as it lock main
thread.

any ideas?

Regards,
Anton
 
I'm looking for simple class to get web-page with some members to
control execution:
1. string Get(string URL) - just get html-page
2. bool Busy - return true while object loading resource
3. Stop() to stop execution

There are problems to use HTTPWebRequest.GetResponse as it lock main
thread.

any ideas?

Well, the most obvious is not to call GetResponse on the UI thread.
Either use a different thread, or use BeginGetResponse instead and
pass in a callback.

Jon
 
I require only an opportunity to stop process and to learn its busy
state.

Well, there's no way of "stopping" a web request when it's been sent,
although you don't need to fetch the whole response, of course. As for
"busy" - I guess that's any time before you've received the whole
response.

Jon
 
I need just to stop data transferring process when Stop() is called
immediately. Is it possible with treads?
 
I'm also Delphi developer, so, for example, in Delphi I create hidden
TWebBrowser component,
then call Navigate(URL), and can use Busy: boolean property as well as
Stop method.
 
The WebRequest (which HttpWebRequest derives from) has an Abort method
which can be used to abort a request.
 
but when HTTPWebRequest is called, thread is blocked,
and we can wait for GetResponse method.
So, we can't call Abort() method
 
but when HTTPWebRequest is called, thread is blocked,
and we can wait for GetResponse method.
So, we can't call Abort() method

So don't use GetResponse - use BeginGetResponse, as I suggested
before.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top