In c# I create use a EventWaitHandle to create a named autorest event the is initially not signaled.
If the EventWaithandle instance is used thread method handler called by using task.Run the WaitOne method does NOT work. The code in the thread method method does not stop at the line of code and wait for a Set method be called so the next line of code can be called.
If the EventWaitHandle instance is used thread method handler using the Thread class, the WaitOne method does work. The code does stop at WaitOne method call until the Set method is called.
Can someone tell WaitOne method DOES NOT work thread handler for the task.Run , but DOES work in thread method for the Thread class?
EventWaitHandle autoReset= autoReset = new EventWaitHandle(false, EventResetMode.AutoReset, TCSInBoundEventWaitName);
Task.Run(() => AutoResetMethod());
static Task<int> AutoResetMethod()
{
autoReset.WaitOne();// DOES NOT WAIT HERE FROM A SET TO BE CALLED TO CONINTUE TO THE NEXT LINKE
..........
Thread t1 = new Thread(new ThreadStart(AutoResetMethod1));
ti.Start();
static void AutoResetMethod1()
{
autoReset.WaitOne();// DOES WAIT HERE UNTIL SET METHOD CALL FOR IT TO CONINTUE