Re: Strange problem with streamwriter & webrequest

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 07/27/04


Date: Tue, 27 Jul 2004 08:08:53 +0100


 <"=?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?=" <the friendly
display name@discussions.microsoft.com>> wrote:

<snip>

> The file i try to download is a ascii text file, and the only reason
> i have chosen it, was, because google has shown it as one of the
> first, for my search for text files.
>
> The code is really simple, the problem is:
>
> It hangs. Try to compile this, the first bytes are shown in the
> console, and are written into the log2.txt file, but, then.. it does
> nothing, til the thread sleep is over.

It doesn't hang, actually. It throws an exception in the worker thread,
which isn't seen. The problem is that you're closing the StreamWriter
and then trying to write to it again.

> If i remove
>
> sw.Write(s) and sw.Close from the whencomplete callback, the whole
> ascii file is going to be displayed in the console. (unlike before,
> only few bytes of it are shown, then, it hangs)
>
> And now the interesting part:
>
> if i copy the text file to my local computer, into the
> inetpub\wwwroot folder (i have iis 5 installed, the OS is windows
> 2000 professional), activate the iis, and change the path in the
> maker function for the textfile to http://localhost/battery.txt , the
> application works fine. It displays all the contents of the text
> file, while copying to the log2.txt without any problems.

That sounds very odd - are you sure you hadn't made any other changes
to the code, such as raising the buffer size or removing the call to
sw.Close()?

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Performance problem related to sysfader, msdtc, davcdata
    ... Documents submenu on the Start Menu sysfader seems to ... but now it just hangs. ... there are no applications running. ... continues to display the menu) ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: 10046 trace: latch free then db file seq. read waits
    ... SQL> sta param k_buffers ... must display, then it hangs for about 2 minutes. ...
    (comp.databases.oracle.server)
  • Re: Outlook 2007 hangs with dw20.exe
    ... Thanks Brian. ... I disabled DWWIN but Outlook still hangs the system when we try to display the insert. ... The dump does not happen with any other tasks - just when trying to open these inserts in Outlook. ...
    (microsoft.public.outlook)
  • Re: System not booting
    ... Eserver pSeriesDiagnostic Information for Multiple Bus Systems Version ... It hangs with 518 on LED display. ... Select the console display for the diagnostics. ...
    (AIX-L)