CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2002
    Location
    WA
    Posts
    223

    Is it possible to signal AutoResetEvent from one thread to another?

    subj?

  2. #2
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    Code:
    public class SomeClass
    {
        protected AutoResetEvent evt;
        
        protected void Thread1Fnc()
        {
            evt.WaitOne();
            MessageBox.Show("Thread1: The event has been signaled");
        } 
    
        protected void Thread2Fnc()
        {
            MessageBox.Show("Thread2: Press OK to signal the event");
            evt.Set();
        }
    
        // ...
        public void Test()
        {
            evt = new AutoResetEvent(false);
            Thread th1 = new Thread(ThreadStart(Thread1Fnc));
            Thread th2 = new Thread(ThreadStart(Thread2Fnc));
            th1.Start();
            th2.Start();
        }
    }
    Martin

  3. #3
    Join Date
    Jan 2002
    Location
    WA
    Posts
    223
    wow thankx

  4. #4
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    my method is same as martin the only diff is i keep all objects n 1 class so that i can access that ref. in thread.

    Paresh

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

Featured