Results 1 to 4 of 4

Thread: Inheriting Web Client to add a timeout property

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Inheriting Web Client to add a timeout property

    Hello,

    VS 2008

    I am not sure how much work there is to inheriting from the web client class.

    Currently I am using it in my project. And I can't change to anything else. The customer would like to have a timeout after a certain period of time. The web client doesn't have this.

    So rather than re-invent the wheel, I am thinking of inheriting from the web client and adding this property.

    Do you think this is a suitable solution? Could it mean more work just to add this. What is the easiest way to go about this?

    Many thanks,
    steve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Inheriting Web Client to add a timeout property

    Even if you add a Timeout property to the class, how will you use it? You still have to call the same methods to actually do anything and they still don't have a timeout.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: Inheriting Web Client to add a timeout property

    Hello,

    I was thinking of using the tool I think is called ??? Refractor to see how they implement this in the web client.

    I know I have to implement the methods along with the property to specify the duration.

    I have used inheritance before. However, never had to do anything this complex. However, for a first time, I would like to try and see if I can get this to work.

    "Nothing gained if nothing tried" or "Nothing ventured nothing gained"
    steve

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Inheriting Web Client to add a timeout property

    I'm not really sure how this would work because, if you MUST use a WebClient then it's presumably because you need to call specific methods of that WebClient. If you use a derived class instead then you simply won't be able to use any methods of the WebClient class because, as soon as you do, you have to wait for them to complete and your timeout is ignored.

    I think the best option for you is to just keep using a vanilla WebClient and simply call its asynchronous methods instead of the synchronous ones. You can then simply wait for a certain period of time for a result and then just move on if it doesn't appear.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width