public delegate void myDel();//declare delegate
static void Main(string[] args)
{
myDel Del;
Thread myThread;
program2 myOb = new program2();
Del = new myDel(myOb.helloMethod);
myThread = new Thread(new ThreadStart(Del));
myThread.Start();
for (int i=0;i<100000;i++)//main thread
{
Console.WriteLine(i);
}
}
}
class program2
{
public void helloMethod()
{
for (int i = 0; i < 10000; i++)//run 10000 times..second thread
{
Console.WriteLine("This is my second thread");
//Thread.Sleep(2000);
}
}
}
I am trying some simple multithreading. Rather than just using the commented Thread.Sleep(); How could I just suspend this thread using myThread.Suspend()?
I assume I would have to pass myThread as an argument to helloMethod?