I want to implement the following logic:
private static AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
static void Main(string[] args)
{
var someObjectInstance = new SomeObject();
someObjectInstance.SomeEvent += SomeEventHandler;
_autoResetEvent.WaitOne();
//...
}
static void SomeEventHandler()
{
_autoResetEvent.Set();
}
So the Main method should wait till SomeEvent is called the first time. As I understand _autoResetEvent.WaitOne blocks the thread so SomeEvent should be raised in another thread. But how can I guarantee it?