---
title: "C# .net event handler delegate question"  
description: "C# .net event handler delegate question"  
author: "Dag Hammarskjold"  
published: 2013-08-10  
updated: 2013-08-10  
canonical: https://www.mindstick.com/forum/1371/c-sharp-dot-net-event-handler-delegate-question  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# C# .net event handler delegate question

Class A includes a [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) 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](https://www.mindstick.com/forum/2084/button-click-event-handler-fired-on-page-refresh) UpdateClassVar(EventArgs e) - which is what it waits for.\

[Question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time): How do I used Event Handler to [trigger](https://www.mindstick.com/blog/167/triggers-in-wpf) next step in Class C ( // do something ) that is dependent on [Status Update](https://answers.mindstick.com/qa/96383/is-a-tweet-like-a-facebook-status-update) without relying on a [Thread.Sleep](https://www.mindstick.com/forum/161218/what-is-the-role-of-thread-sleep-in-multithreading-and-when-should-it-be-avoided)... ??

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](https://www.mindstick.com/forum/156093/what-is-considered-as-more-significant-creating-content-or-building-backlinks) only one [prototype](https://www.mindstick.com/news/2386/every-detail-regarding-twitter-leak-of-xiaomi-outfolding-smartphone-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](https://www.mindstick.com/forum/2324/what-is-the-alternative-to-the-mvc), 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 */
```

## Replies

### Reply by Pravesh Singh

Hello!

I think that AutoResetEvent(http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx) 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.


---

Original Source: https://www.mindstick.com/forum/1371/c-sharp-dot-net-event-handler-delegate-question

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
