🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: thread

#21932
From: news.gazeta.pl
Date: Thu, 23 Dec 2010 08:13
81 lines
2661 bytes
Użytkownik "3P" <nospam@serwer.pl> napisał w wiadomości 
news:op.vn4y2yekmsp0fz@mcs...
> 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 zakonczya w?tek. Przyk3ad:
>>
>> 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) Chce przerwaa 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?zaa?
>>
>> Z góry dziekuje
>>
> Najpierw poczytaj o widoczności/zasięgu zmiennych, a potem bierz się za 
> wątki.
> W szczególności poczytaj co to zmienne lokalne.

To raczej czeski błąd w definicji thread.
Oczywiście że miało być: thread = new
>> System.Threading.Thread(ThreadMethod);
Dzieki

>
> __________ Informacja programu ESET NOD32 Antivirus, wersja bazy sygnatur 
> wirusow 5726 (20101222) __________
>
> Wiadomosc zostala sprawdzona przez program ESET NOD32 Antivirus.
>
> http://www.eset.pl lub http://www.eset.com
>
> 



__________ Informacja programu ESET NOD32 Antivirus, wersja bazy sygnatur wirusow 5726 (20101222) __________

Wiadomosc zostala sprawdzona przez program ESET NOD32 Antivirus.

http://www.eset.pl lub http://www.eset.com 
Technical Details
Message-ID: <iev0ai$6c2$1@inews.gazeta.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
References: <ietog2$e1l$1@inews.gazeta.pl> <op.vn4y2yekmsp0fz@mcs>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: "news.gazeta.pl" <szymon.mitek@gazeta.pl>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: thread
Date: Thu, 23 Dec 2010 09:13:57 +0100
Organization: "Portal Gazeta.pl -> http://www.gazeta.pl"
Lines: 85
Message-ID: <iev0ai$6c2$1@inews.gazeta.pl>
References: <ietog2$e1l$1@inews.gazeta.pl> <op.vn4y2yekmsp0fz@mcs>
NNTP-Posting-Host: 213.76.145.194
X-Trace: inews.gazeta.pl 1293091986 6530 213.76.145.194 (23 Dec 2010 08:13:06 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Thu, 23 Dec 2010 08:13:06 +0000 (UTC)
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994
X-Priority: 3
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-User: szymonm77
X-EsetScannerBuild: 8423
X-MSMail-Priority: Normal
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit