Article View: alt.pl.comp.lang.csharp
Article #21930thread
From: news.gazeta.pl
Date: Wed, 22 Dec 2010 20:54
Date: Wed, 22 Dec 2010 20:54
61 lines
1795 bytes
1795 bytes
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ę
__________ Informacja programu ESET NOD32 Antivirus, wersja bazy sygnatur wirusow 5724 (20101222) __________
Wiadomosc zostala sprawdzona przez program ESET NOD32 Antivirus.
http://www.eset.pl lub http://www.eset.com
Technical Details
Message-ID:
<ietog2$e1l$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailShow 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: thread Date: Wed, 22 Dec 2010 21:54:21 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 65 Message-ID: <ietog2$e1l$1@inews.gazeta.pl> NNTP-Posting-Host: ip-091201121196.mikolow.multimetro.pl X-Trace: inews.gazeta.pl 1293051203 14389 91.201.121.196 (22 Dec 2010 20:53:23 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 22 Dec 2010 20:53:23 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-Priority: 3 X-RFC2646: Format=Flowed; Original X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-User: szymonm77 X-EsetScannerBuild: 8417 X-MSMail-Priority: Normal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit