Results 1 to 2 of 2

Thread: Suspending and Resuming a Thread?

Threaded View

  1. #1

    Thread Starter
    Lively Member neodatatype's Avatar
    Join Date
    Aug 2002
    Location
    Italy
    Posts
    103

    Question Suspending and Resuming a Thread?

    Hi all!


    I would like to suspend a thread and then resume it with the same procedure.

    I would expected that this code (you can just cut-and-paste into a new console project) will do the thing, but when i do the Resume() nothing happen!

    Why it does not restart the Execute() procedure???

    PHP Code:
    using System
    using System.Threading

    namespace 
    thread 


    public class 
    Class1 


    public static 
    void Main() 

    ThreadedClass t = new ThreadedClass(); 

    t.Start(); 
    Thread.Sleep(10); 
    t.Suspend(); 
    Console.WriteLine("NOW RESUME!");
    t.Resume(); 
    Thread.Sleep(10); 
    t.Abort(); 





    public class 
    ThreadedClass 

    private 
    Thread oThread

    public 
    ThreadedClass() 

    oThread = new Thread(new ThreadStart(this.Execute)); 


    public 
    void Start() 

    oThread.Start(); 


    public 
    void Abort() 

    oThread.Abort(); 
    oThread.Join(); 



    public 
    void Suspend() 

    oThread.Suspend(); 


    public 
    void Resume() 

    oThread.Resume(); 


    private 
    void Execute() 

    do 

    Console.WriteLine(DateTime.Now.ToString() + " - Executing"); 

    while (
    true); 





    Last edited by neodatatype; Mar 2nd, 2003 at 10:30 AM.
    > NeoDataType.net <

    Try my Free .Net Reporting Tool!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width