🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #21931

Re: thread

#21931
From: 3P
Date: Wed, 22 Dec 2010 22:22
55 lines
1788 bytes
Dnia 22-12-2010 o 21:54:21 news.gazeta.pl <szymon.mitek@gazeta.pl>  
napisał(a):

> Pro¶ba o pomoc.
> W jaki sposób zakoñczyæ w±tek. Przyk³ad:
>
> 1) Uruchamiam w±tek - jest ok
>
> System.Threading.Thread thread = null;
>
> private void button1_Click(object sender, RoutedEventArgs e)
>
> {
>
> System.Threading.Thread thread = new  
> System.Threading.Thread(ThreadMethod);
>
> thread.Start();
>
>
> }
>
> 2)Metoda :
>
> private void ThreadMethod(object parameters)
>
> {
>
>
> while (true)
>
> {
>
> MessageBox.Show("test");
>
> }
>
> }
>
> 3) Chcê przerwaæ w±tek na click
>
> private void button2_Click(object sender, RoutedEventArgs e)
> {
>
> thread.Abort();
>
> }
>
> Problem jest przy przerwaniu. thread jest null. Jak to mo¿na rozwi±zaæ?
>
> Z góry dziekujê
>
Najpierw poczytaj o widoczności/zasięgu zmiennych, a potem bierz się za  
wątki.
W szczególności poczytaj co to zmienne lokalne.
Technical Details
Message-ID: <op.vn4y2yekmsp0fz@mcs>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!news.onet.pl!.POSTED!not-for-mail
References: <ietog2$e1l$1@inews.gazeta.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!news.onet.pl!.POSTED!not-for-mail
From: 3P <nospam@serwer.pl>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: thread
Date: Wed, 22 Dec 2010 23:22:00 +0100
Organization: http://onet.pl
Lines: 55
Message-ID: <op.vn4y2yekmsp0fz@mcs>
References: <ietog2$e1l$1@inews.gazeta.pl>
NNTP-Posting-Host: 83.238.118.3
Mime-Version: 1.0
X-Trace: news.onet.pl 1293056536 14772 83.238.118.3 (22 Dec 2010 22:22:16 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Wed, 22 Dec 2010 22:22:16 +0000 (UTC)
User-Agent: Opera Mail/11.00 (Win32)
X-Antivirus: avast! (VPS 101222-1, 2010-12-22), Outbound message
X-Antivirus-Status: Clean
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit