Created
May 7, 2022 06:40
-
-
Save trkyshorty/5eda35febb09caf814784137506cf21d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
private void MyThread() | |
{ | |
try | |
{ | |
while (true) | |
{ | |
//Thread içerisinde ne çalışacaksa buraya | |
Console.WriteLine('Merhaba!'); //Konsola merhaba yazılıyor! | |
Thread.Sleep(1250); //Thread 1.25 saniye durdur - bunu düşürebilirsin ancak kaldırma işlemcinin anasını ağlatır | |
}; | |
} | |
catch (ThreadAbortException ex) | |
{ | |
Console.WriteLine("Thread is aborted and the code is " | |
+ ex.ExceptionState); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.StackTrace); | |
} | |
} | |
public void ThreadStart() | |
{ | |
Thread t = new Thread(new ThreadStart(MyThread)); | |
t.IsBackground = true; //thread arkaplanda çalışıyor | |
t.Start(); //threadi başlat | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment