Thread_Suspend.cs(12,1): warning CS0618: 'System.Threading.Thread.Suspend()' is obsolete: 'Thread.Suspend has been deprecated. Please use other classes in
System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.
http://go.microsoft.com/fwlink/?linkid=14202'
And my code are:
using System;
using System.Threading;
namespace my{
class program{
static Thread th;
static void Main(){
th=new Thread(MyFunction);
th.Name="My Thread";
Console.WriteLine("Threading start......");
th.Start();
Thread.Sleep(10000);
th.Suspend();
Console.WriteLine("Now Thread Suspended.");
}
static void MyFunction(){
int i;
for(i=1;i<25;i++)
{
int time=new Random().Next(25,50);
Console.WriteLine("Thread {0} display and then thread suspend for {1} milliseconds",th.Name,time.ToString());
Thread.Sleep(time);
}
}
}
}
VulpesPosted Jul 7, 2013, 7:00 PM
Sanjeeb LenkaPosted Jul 7, 2013, 2:24 PM
Check these links for example.
http://programsnippets.wordpress.com/2013/04/21/sample-to-create-start-pause-resume-and-terminate-a-thread-in-c/
http://codesmesh.com/threading-in-c-sharp-with-example/
Arun KurmiPosted Jul 7, 2013, 1:46 PM
Arun KurmiPosted Jul 7, 2013, 1:41 PM
VulpesPosted Jul 7, 2013, 10:31 AM
Iftikar HussainPosted Jul 7, 2013, 9:56 AM
Please refer the below link
http://stackoverflow.com/questions/382173/what-are-alternative-ways-to-suspend-and-resume-a-thread
http://stackoverflow.com/questions/4509067/c-sharp-threading-suspend-in-obsolete-thread-has-been-deprecated
http://www.codeproject.com/Questions/352351/Alternate-way-for-Thread-Suspend-and-Thread-Resume
Regards,
Iftikar