Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4119228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:03:49+00:00 2026-05-20T23:03:49+00:00

Class A includes a variable A to hold the status of an event that

  • 0

Class A includes a variable A to hold the status of an event that is triggered in Class C ( doEvent() ). The thread sleeps for 500 ms as it waits for Class B to kick off an Event which send the EventArg data back to Class C and calls an Event Handler UpdateClassVar(EventArgs e) – which is what it waits for.

Question: How do I used Event Handler to trigger next step in Class C ( // do something ) that is dependent on Status Update without relying on a Thread.Sleep… ??

Disclaimer: Consider me a novice programmer. Consider this my best attempt and a fairly non-elegant solution. Please feel free to re-design and re-code, this should be considered as only one prototype effort to solve above issue.

NOTE: Code Exampled Edited for ‘real – world’ example that should actually work. ( not fully tested )

Additional Question – Thread.Sleep(400) in example below stops main thread… halting all processes, although looking for an alternative, is this even a viable solution??

 public class OrderA : ICurrencyOrder
 {
     private int _clid;

     private string _status;

     public int Clid
     {
         get { return _clid; }

         set { _clid = value; }
     }

     public string Status
     {
         get { return _status; }

         set { _status = value; }
     }

 }


 Class B
 {

      // event delegate for UpdateOrder

      public event UpdateOrderDelegate UpdateOrderEvent;

      /* Code Here to receive and process order assign status etc */

      /* An Event Arguments (args)  Class is created that hold e.Status and e.Clid values */

      UpdateOrder(args)

      private void UpdateOrder(args)
      {
           if (UpdateOrderEvent != null)
           {
               UpdateOrderEvent(this, e);
           }
      }

 }


// This is the class that initates the order (sendOrder()) and then waits for the 
// status of the order before processing the next step in the order process
// which could be to send order again to exit

 Class C
 {
      // add event handler to update status and clid from Class B

      UpdateOrderEvent += new UpdateOrderDelegate(UpdateOrdersListener);

      public void EnterOrder(EnterEventArgs e)
      {

      // set connectinon to ICurrencyOrder class above OrderA
      // this uses a switch statement (omitted) to use correct class (A, B, C etc).

      ICurrencyOrder ordVals = Class A;

      bool fill = false;

      for (int i=0; i<5 && fill=false; i++)
      {
           sendOrder("Symbol", price, clid, etc)

           Thread.Sleep(400);

           if (ordVals.Clid = clid)   // check to see if order was updated using client id
           {
                if (ordVals.Status = 'FILLED')
                {
                     filled = true;
                }

           }

      }    // end for loop

      }   // end EnterOrder

      private void UpdateOrdersListener(object sender, EventArgs e)
      {
          OrderUpdateEventArgs ev = (OrderUpdatEventArgs)e;

          // set connection to appropriate class using switch (symbol) omitted

          ICurrencyOrder ordVal = Class A;

          ordVal.Status = e.Status;

          ordVal.Clid = e.Clid;

      }  // end Class C
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:03:50+00:00Added an answer on May 20, 2026 at 11:03 pm

    I think that AutoResetEvent is the class you are looking for if you want to wait for something to happen before continuing doing something else.

    There is an example provided at the class description page, basically you call WaitOne where you want to wait, and Set when you want to continue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing some unit tests for a business-logic class that includes validation
Do class, method and variable names get included in the MSIL after compiling a
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
My style of coding includes the following idiom: class Derived : public Base {
I have a html component that includes some javascript. The component is a file
I have a class imgmanager that allows me to load all my images exactly
#include iostream class A { private: int a; public : A(): a(-1) {} int
#include iostream #include vector class ABC { private: bool m_b; public: ABC() : m_b(false)
#include iostream #include vector class ABC { }; class VecTest { std::vector<ABC> vec; public:
#include<iostream> class name { public: int a; name():a(0){}; }; void add(name * pname) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.