Ejemplo n.º 1
0
        /// <summary>
        /// 热键事件监听器
        /// </summary>
        public void NamedEventThreadProc()
        {
            myNamedEvent = new NamedEvent("ScktMyEventSckt", false, false);//wait to get signaled
            IntPtr[] waitHandles = new IntPtr[2];
            waitHandles[0] = myNamedEvent.Handle;
            waitHandles[1] = appShutdown.Handle;

            while (true)
            {
                uint ret = 0;
                try
                {
                    ret = NamedEvent.WaitForMultipleObjects(waitHandles, false, 0xFFFFFFFF);//wait for ever
                }
                catch (System.ComponentModel.Win32Exception exp)
                {
                    string err = exp.ToString();
                }
                if (ret == 1)
                {
                    break;
                }
                else
                {
                    if (ret == 0)
                    {
                        if (socketScanner.IsScannerConnected())
                        {
                            //委托调用,执行扫描函数
                            this.triggerClick.Invoke();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static NamedEvent OpenExisting( string name )
 {
     NamedEvent evt=new NamedEvent();
     // 0x1F0003==EVENT_ALL_ACCESS
     evt.Handle=OpenEvent( 0x1F0003, false, name );
     if( evt.Handle==IntPtr.Zero )
         throw new System.ComponentModel.Win32Exception( (int)GetLastError() );
     return evt;
 }
Ejemplo n.º 3
0
        public static NamedEvent OpenExisting(string name)
        {
            NamedEvent evt = new NamedEvent();

            // 0x1F0003==EVENT_ALL_ACCESS
            evt.Handle = OpenEvent(0x1F0003, false, name);
            if (evt.Handle == IntPtr.Zero)
            {
                throw new System.ComponentModel.Win32Exception((int)GetLastError());
            }
            return(evt);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 启动热键支持
 /// </summary>
 internal void EnableHotKeySupport()
 {
     try
     {
         myNamedEvent = NamedEvent.OpenExisting("ScktMyEventSckt");
         myNamedEvent.Set();
         myNamedEvent.Close();
     }
     catch (System.ComponentModel.Win32Exception exp)
     {
         threadWaitTrigger = new Thread(new ThreadStart(NamedEventThreadProc));
         appShutdown       = new NamedEvent("SocketCSharpSampleShudown", false, false);
         threadWaitTrigger.Start();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// ����ȼ�֧��
 /// </summary>
 internal void EnableHotKeySupport()
 {
     try
     {
         myNamedEvent = NamedEvent.OpenExisting("ScktMyEventSckt");
         myNamedEvent.Set();
         myNamedEvent.Close();
     }
     catch (System.ComponentModel.Win32Exception exp)
     {
         threadWaitTrigger = new Thread(new ThreadStart(NamedEventThreadProc));
         appShutdown = new NamedEvent("SocketCSharpSampleShudown", false, false);
         threadWaitTrigger.Start();
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// �ȼ��¼�������
        /// </summary>
        public void NamedEventThreadProc()
        {
            myNamedEvent = new NamedEvent("ScktMyEventSckt", false, false);//wait to get signaled
            IntPtr[] waitHandles = new IntPtr[2];
            waitHandles[0] = myNamedEvent.Handle;
            waitHandles[1] = appShutdown.Handle;

            while (true)
            {
                uint ret = 0;
                try
                {
                    ret = NamedEvent.WaitForMultipleObjects(waitHandles, false, 0xFFFFFFFF);//wait for ever
                }
                catch (System.ComponentModel.Win32Exception exp)
                {
                    string err = exp.ToString();
                }
                if (ret == 1)
                {
                    break;
                }
                else
                {
                    if (ret == 0)
                    {
                        if (socketScanner.IsScannerConnected())
                        {
                            //ί�е��ã�ִ��ɨ�躯��
                            this.triggerClick.Invoke();
                        }
                    }
                }
            }
        }