Skip to content

Instantly share code, notes, and snippets.

@trkyshorty
Created May 7, 2022 06:40
Show Gist options
  • Save trkyshorty/5eda35febb09caf814784137506cf21d to your computer and use it in GitHub Desktop.
Save trkyshorty/5eda35febb09caf814784137506cf21d to your computer and use it in GitHub Desktop.
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