Esempio n. 1
0
        private void waitForManualResetEvent()
        {
            long WaitRet = API_ERROR;

            int[] handlesNotify = new int[2];
            int   count;
            bool  bNotifyAEventSet = false;
            bool  bNotifyBEventSet = false;

            CreateNamedManualResetEvent(SABRE_API_NOTIFY_A, ref handlesNotify[0]);
            CreateNamedManualResetEvent(SABRE_API_NOTIFY_B, ref handlesNotify[1]);

            WaitRet = MySabreAPI.WaitForMultipleObjects(2, ref handlesNotify[0], 0, INFINITE);
            if (WaitRet == MySabreAPI.WAIT_OBJECT_0)
            {
                bNotifyAEventSet = true;
            }
            if (MySabreAPI.WAIT_OBJECT_0 + 1 == WaitRet)
            {
                bNotifyBEventSet = true;
            }
            if (bNotifyAEventSet | bNotifyBEventSet)
            {
                checkStateChange();
            }
            do
            {
                bool bWaitingOnA = !bNotifyAEventSet;
                if (bWaitingOnA)
                {
                    count = 0;
                }
                else
                {
                    count = 1;
                }
                WaitRet = MySabreAPI.WaitForSingleObject(handlesNotify[count], -1);
                if (WaitRet == MySabreAPI.WAIT_OBJECT_0)
                {
                    bNotifyAEventSet = bWaitingOnA;
                    checkStateChange();
                }
            } while (true);
        }
Esempio n. 2
0
        private static bool isEventSet(string eventName)
        {
            bool bEventSet = false;
            int  hEvent    = API_ERROR;
            long WaitRet;

            hEvent = MySabreAPI.OpenEvent(MySabreAPI.EVENT_ALL_ACCESS, 0, ref eventName);
            if (hEvent != 0)
            {
                WaitRet = MySabreAPI.WaitForSingleObject(hEvent, 0);
                MySabreAPI.CloseHandle(hEvent);
                if (MySabreAPI.WAIT_OBJECT_0 == WaitRet)
                {
                    bEventSet = true;
                }
            }

            return(bEventSet);
        }