none
ManualResetEvent RRS feed

  • Question

  • Hello Fellas,

    How to define the current state of that Handle?
    Say when I apply QuickView? Set or Reset?

    Well asking WaitOne() will result yo true or false
    But is it the same TRUE/FALSE that was during initialization?
    ManualResetEvent Waitor = new ManualResetEvent(false);

    ========================================
    I decided to extend my Q.
    Actually I use that handle inside some Thread as its internal element.

    I can't make it as static and volatile, but I suppose when I set it from outside using internal Lambda code, it doesn't want to be set.. 
    Seems like the same situation why volatile has been issued as part of declaration.

    So, I would ask now more focused: how to emulate volatile feature of a field but inside a Thread?

    SomeThread() {
      volatile bool IsTrue = false;
      // Now I am sure there is only one copy of that data 
      // inside the Thread compartment
    
        while(!IsTrue) {
         // Working hard here
             }
      }

    Thakns



    "I = I + 1" .. Isn't it boolshit?




    • Edited by RobbKirk Wednesday, October 16, 2019 8:54 AM
    Wednesday, October 16, 2019 8:19 AM

Answers

  • Without knowing more of your usage one possiblity if that is required is to use ManualResetEventSlim class; it has IsSet property.
    • Marked as answer by RobbKirk Wednesday, October 16, 2019 9:37 AM
    Wednesday, October 16, 2019 9:02 AM

All replies

  • Without knowing more of your usage one possiblity if that is required is to use ManualResetEventSlim class; it has IsSet property.
    • Marked as answer by RobbKirk Wednesday, October 16, 2019 9:37 AM
    Wednesday, October 16, 2019 9:02 AM
  • Without knowing more of your usage one possiblity if that is required is to use ManualResetEventSlim class; it has IsSet property.
    Good advice, haven't heard about it )) Thank you MasaSam!!
    Now I do 
        class VolatileManualResetEvent
        {
            public volatile ManualResetEvent Handle;
            public VolatileManualResetEvent(bool state) { Handle = new ManualResetEvent(state); }
        }


    "I = I + 1" .. Isn't it boolshit?

    Wednesday, October 16, 2019 9:37 AM