Article View: pl.comp.lang.c
Article #272360Re: [SGCL] Odśmiecania współbieżnego ciąg dalszy
From: Sebastian Nibisz
Date: Wed, 27 Feb 2008 20:29
Date: Wed, 27 Feb 2008 20:29
26 lines
1875 bytes
1875 bytes
> void Cos() {
> FileStream x = new ....
> using( BinaryWriter br = new BinaryReader (x) ) {
> //blabla
> }
> }
>
> Pytanie 1:
> Kiedy fs zwolni zasoby 'handle' do plikow.
Kiedy GC przyjdzie na to ochota. Nie zawołałes Dispose dla obiektu
FileStream, tak więc skazałeś się na łaskę systemu GC.
Powinno byc tak:
using (FileStream fs = new FileStream(...))
{
using (BinaryWriter br = new BinaryWriter(fs))
{
// blabla
}
}
Pozdrawiam.
- Bastek -
Technical Details
Message-ID:
<fq4h76$b2i$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<fppvdq$68v$1@inews.gazeta.pl> <fq0od3$5bm$1@inews.gazeta.pl> <fq0qpa$ekv$1@inews.gazeta.pl> <fq0s58$jvv$1@inews.gazeta.pl> <fq0tjl$shn$1@news.vectranet.pl> <fq10ir$8nn$1@inews.gazeta.pl> <fq140s$2u6$1@news.vectranet.pl> <fq164t$3bl$1@inews.gazeta.pl> <fq1mqa$kqq$1@news.vectranet.pl> <fq42jk$k6t$1@bozon2.softax.pl> <fq4co0$5en$1@news2.task.gda.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: "Sebastian Nibisz" <EBA_K@poczta.onet.pl> Newsgroups: pl.comp.lang.c Subject: Re: [SGCL] Odśmiecania współbieżnego ciąg dalszy Date: Wed, 27 Feb 2008 21:29:20 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 27 Message-ID: <fq4h76$b2i$1@inews.gazeta.pl> References: <fppvdq$68v$1@inews.gazeta.pl> <fq0od3$5bm$1@inews.gazeta.pl> <fq0qpa$ekv$1@inews.gazeta.pl> <fq0s58$jvv$1@inews.gazeta.pl> <fq0tjl$shn$1@news.vectranet.pl> <fq10ir$8nn$1@inews.gazeta.pl> <fq140s$2u6$1@news.vectranet.pl> <fq164t$3bl$1@inews.gazeta.pl> <fq1mqa$kqq$1@news.vectranet.pl> <fq42jk$k6t$1@bozon2.softax.pl> <fq4co0$5en$1@news2.task.gda.pl> NNTP-Posting-Host: s178pc190.mmj.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1204144166 11346 85.219.178.190 (27 Feb 2008 20:29:26 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 27 Feb 2008 20:29:26 +0000 (UTC) In-Reply-To: <fq4co0$5en$1@news2.task.gda.pl> X-Antivirus-Status: Clean X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545 X-Priority: 3 X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-User: eba_k X-Antivirus: avast! (VPS 080227-0, 2008-02-27), Outbound message X-MSMail-Priority: Normal Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit