Пример #1
0
 public void NT_CancelPollEntryListener(NtEntryListenerPoller poller)
 {
     Native_NT_CancelPollEntryListener(poller);
 }
        private CancellationTokenSource CreateEntryListenerThread()
        {
            m_entryListenerPoller = NtCore.CreateEntryListenerPoller(Handle);
            CancellationTokenSource source = new CancellationTokenSource();
            var ret = new Thread(() =>
            {
                bool wasInterrupted = false;
                var token           = source.Token;
                token.Register(() =>
                {
                    NtCore.CancelPollEntryListener(m_entryListenerPoller);
                });
                while (!token.IsCancellationRequested)
                {
                    var events = NtCore.PollEntryListener(m_entryListenerPoller);
                    if (token.IsCancellationRequested)
                    {
                        NtCore.DisposeEntryListenerSpan(events);
                        break;
                    }
                    if (events.Length == 0)
                    {
                        NtCore.DisposeEntryListenerSpan(events);
                        lock (m_entryListenerWaitQueueLock)
                        {
                            if (m_entryListenerWaitQueue)
                            {
                                m_entryListenerWaitQueue = false;
                                Monitor.PulseAll(m_entryListenerWaitQueueLock);
                                continue;
                            }
                        }
                        wasInterrupted = true;
                        break;
                    }
                    for (int i = 0; i < events.Length; i++)
                    {
                        EntryNotificationDelegate?listener;
                        lock (m_entryListenerLock)
                        {
                            m_entryListeners.TryGetValue(events.Pointer[i].listener, out listener);
                        }
                        if (listener != null)
                        {
                            listener(new RefEntryNotification(this, events.Pointer[i]));
                            if (token.IsCancellationRequested)
                            {
                                break;
                            }
                        }
                    }
                    NtCore.DisposeEntryListenerSpan(events);
                }
                lock (m_entryListenerWaitQueueLock)
                {
                    if (!wasInterrupted)
                    {
                        NtCore.DestroyEntryListenerPoller(m_entryListenerPoller);
                    }
                    m_entryListenerPoller = new NtEntryListenerPoller();
                }
            })
            {
                Name         = "NTEntryListener",
                IsBackground = true
            };

            ret.Start();
            m_entryListenerThread = ret;
            return(source);
        }
Пример #3
0
 public NtEntryNotification *NT_PollEntryListenerTimeout(NtEntryListenerPoller poller, UIntPtr *len, double timeout, NtBool *timed_out)
 {
     return(Native_NT_PollEntryListenerTimeout(poller, len, timeout, timed_out));
 }
Пример #4
0
 private static extern void Native_NT_CancelPollEntryListener(NtEntryListenerPoller poller);
Пример #5
0
 public NtEntryNotification *NT_PollEntryListener(NtEntryListenerPoller poller, UIntPtr *len)
 {
     return(Native_NT_PollEntryListener(poller, len));
 }
Пример #6
0
 private static extern NtEntryNotification *Native_NT_PollEntryListenerTimeout(NtEntryListenerPoller poller, UIntPtr *len, double timeout, NtBool *timed_out);
Пример #7
0
 public NtEntryListener NT_AddPolledEntryListenerSingle(NtEntryListenerPoller poller, NtEntry entry, uint flags)
 {
     return(Native_NT_AddPolledEntryListenerSingle(poller, entry, flags));
 }
Пример #8
0
 private static extern NtEntryNotification *Native_NT_PollEntryListener(NtEntryListenerPoller poller, UIntPtr *len);
Пример #9
0
 private static extern NtEntryListener Native_NT_AddPolledEntryListenerSingle(NtEntryListenerPoller poller, NtEntry entry, uint flags);
Пример #10
0
 public NtEntryListener NT_AddPolledEntryListener(NtEntryListenerPoller poller, byte *prefix, UIntPtr prefix_len, uint flags)
 {
     return(Native_NT_AddPolledEntryListener(poller, prefix, prefix_len, flags));
 }
Пример #11
0
 private static extern NtEntryListener Native_NT_AddPolledEntryListener(NtEntryListenerPoller poller, byte *prefix, UIntPtr prefix_len, uint flags);
Пример #12
0
 public void NT_DestroyEntryListenerPoller(NtEntryListenerPoller poller)
 {
     Native_NT_DestroyEntryListenerPoller(poller);
 }
Пример #13
0
 private static extern void Native_NT_DestroyEntryListenerPoller(NtEntryListenerPoller poller);