Streaming with System.IO and System.Net

Discussion in 'ASP .Net' started by Charles A. Lackman, Dec 8, 2004.

  1. Hello,

    I have an app that has a process bar on it and it sends and retrieves data
    back and forth to a web page using WebRequest and WebResponse. The stream
    is received from the web page and written into a memorystream then written
    to a file on the hard drive. When the app's start button is clicked the
    first thing that happens is that the size of the file is displayed (i.e. 51
    of 562 Downloaded) untile the download is complete. The problem is that
    when you click on the cancel button (to stop the download) or if you click
    around the form or outside of the form, the application stops responding,
    the cancel buttons event does not fire when the steaming is happening.

    Any suggestions will be greatly appreciated.

    Chuck
    Charles A. Lackman, Dec 8, 2004
    #1
    1. Advertising

  2. Seems like the app crashes when focus is changed.

    The focus could remain on the progressbar as I get the impression
    there's really nothing the user is supposed to to until the download
    is done anyway.

    I'd also set a breakpoint on the Cancel button click handler.
    There's housekeeping to be done there for sure.




    "Charles A. Lackman" wrote:

    > Hello,
    >
    > I have an app that has a process bar on it and it sends and retrieves data
    > back and forth to a web page using WebRequest and WebResponse. The stream
    > is received from the web page and written into a memorystream then written
    > to a file on the hard drive. When the app's start button is clicked the
    > first thing that happens is that the size of the file is displayed (i.e. 51
    > of 562 Downloaded) untile the download is complete. The problem is that
    > when you click on the cancel button (to stop the download) or if you click
    > around the form or outside of the form, the application stops responding,
    > the cancel buttons event does not fire when the steaming is happening.
    >
    > Any suggestions will be greatly appreciated.
    >
    > Chuck
    >
    >
    >
    =?Utf-8?B?QmVuIFNvbG9tb24=?=, Dec 8, 2004
    #2
    1. Advertising

  3. Charles A. Lackman

    Scott Emick Guest

    Maybe you could launch a seprate process to do the sending and receiving of
    the data which would periodically update the ui?

    Because your are doing the data retrieval synchronously and therefore cannot
    put doevents anywhere to allow the ui to update/check for events.

    Scott Emick

    "Ben Solomon" <> wrote in message
    news:...
    > Seems like the app crashes when focus is changed.
    >
    > The focus could remain on the progressbar as I get the impression
    > there's really nothing the user is supposed to to until the download
    > is done anyway.
    >
    > I'd also set a breakpoint on the Cancel button click handler.
    > There's housekeeping to be done there for sure.
    >
    >
    >
    >
    > "Charles A. Lackman" wrote:
    >
    >> Hello,
    >>
    >> I have an app that has a process bar on it and it sends and retrieves
    >> data
    >> back and forth to a web page using WebRequest and WebResponse. The
    >> stream
    >> is received from the web page and written into a memorystream then
    >> written
    >> to a file on the hard drive. When the app's start button is clicked the
    >> first thing that happens is that the size of the file is displayed (i.e.
    >> 51
    >> of 562 Downloaded) untile the download is complete. The problem is that
    >> when you click on the cancel button (to stop the download) or if you
    >> click
    >> around the form or outside of the form, the application stops responding,
    >> the cancel buttons event does not fire when the steaming is happening.
    >>
    >> Any suggestions will be greatly appreciated.
    >>
    >> Chuck
    >>
    >>
    >>
    Scott Emick, Dec 10, 2004
    #3
  4. Instead of using sync apis, use the asynchronous versions of
    Httpwebrequest/response. Then, in the callback handler, make sure that you
    post messages to the main window.

    --
    feroze

    -----------------
    This posting is provided as-is. It offers no warranties and assigns no
    rights.

    See http://weblogs.asp.net/feroze_daud for System.Net related posts.
    ----------------

    "Scott Emick" <-international.com> wrote in message
    news:...
    > Maybe you could launch a seprate process to do the sending and receiving

    of
    > the data which would periodically update the ui?
    >
    > Because your are doing the data retrieval synchronously and therefore

    cannot
    > put doevents anywhere to allow the ui to update/check for events.
    >
    > Scott Emick
    >
    > "Ben Solomon" <> wrote in message
    > news:...
    > > Seems like the app crashes when focus is changed.
    > >
    > > The focus could remain on the progressbar as I get the impression
    > > there's really nothing the user is supposed to to until the download
    > > is done anyway.
    > >
    > > I'd also set a breakpoint on the Cancel button click handler.
    > > There's housekeeping to be done there for sure.
    > >
    > >
    > >
    > >
    > > "Charles A. Lackman" wrote:
    > >
    > >> Hello,
    > >>
    > >> I have an app that has a process bar on it and it sends and retrieves
    > >> data
    > >> back and forth to a web page using WebRequest and WebResponse. The
    > >> stream
    > >> is received from the web page and written into a memorystream then
    > >> written
    > >> to a file on the hard drive. When the app's start button is clicked

    the
    > >> first thing that happens is that the size of the file is displayed

    (i.e.
    > >> 51
    > >> of 562 Downloaded) untile the download is complete. The problem is

    that
    > >> when you click on the cancel button (to stop the download) or if you
    > >> click
    > >> around the form or outside of the form, the application stops

    responding,
    > >> the cancel buttons event does not fire when the steaming is happening.
    > >>
    > >> Any suggestions will be greatly appreciated.
    > >>
    > >> Chuck
    > >>
    > >>
    > >>

    >
    >
    Feroze [msft], Jan 13, 2005
    #4
  5. Feroze [msft] wrote:
    > Instead of using sync apis, use the asynchronous versions of
    > Httpwebrequest/response. Then, in the callback handler, make sure
    > that you post messages to the main window.
    >


    ....and since this will be a thread pool thread, make sure that all
    communications with the GUI window is through ISynchronizeInvoke.Invoke

    Richard
    --
    www.richardgrimes.com
    my email is encrypted with ROT13 (www.rot13.org)
    Richard Grimes [MVP], Jan 15, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kennethfine
    Replies:
    1
    Views:
    566
    John Saunders
    Jul 23, 2003
  2. Jordan Marton

    Streaming LIVE Video on My ASP.NET Website

    Jordan Marton, Aug 13, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    728
    Jordan Marton
    Aug 13, 2003
  3. MattC
    Replies:
    1
    Views:
    4,256
    Steve C. Orr [MVP, MCSD]
    Jun 14, 2005
  4. Replies:
    1
    Views:
    496
  5. Alex Wayne
    Replies:
    8
    Views:
    101
    Alex Wayne
    Apr 9, 2008
Loading...

Share This Page