コード例 #1
0
ファイル: Scanner.cs プロジェクト: ddssssdd/TrainCheck
        public bool Start()
        {
            if (I60X0.SCA_GetPowerStatus() == 0)
            {
                I60X0.SCA_EnableModule();
                needClose = true;
            }

            Win32.MSGQUEUEOPTIONS options = new Win32.MSGQUEUEOPTIONS();
            options.dwSize = 20;
            options.dwFlags = 2;
            options.dwMaxMessages = 64;
            options.cbMaxMessage = 32;
            options.bReadAccess = true;

            IntPtr hMsgQ = Win32.CreateMsgQueue(null, options);
            if (hMsgQ == IntPtr.Zero)
            {
                return false;
            }

            hNotify = I60X0.SCA_RegisterNotification(hMsgQ);
            if (hNotify == IntPtr.Zero)
            {
                return false;
            }

            hEvent[0] = Win32.CreateEvent(IntPtr.Zero, false, false, null);
            hEvent[1] = hMsgQ;

            scanThread = new Thread(new ThreadStart(this.ScanThreadPorc));
            scanThread.Start();

            return true;
        }
コード例 #2
0
        public bool Start()
        {
            if (I60X0.SCA_GetPowerStatus() == 0)
            {
                I60X0.SCA_EnableModule();
                needClose = true;
            }

            Win32.MSGQUEUEOPTIONS options = new Win32.MSGQUEUEOPTIONS();
            options.dwSize        = 20;
            options.dwFlags       = 2;
            options.dwMaxMessages = 64;
            options.cbMaxMessage  = 32;
            options.bReadAccess   = true;

            IntPtr hMsgQ = Win32.CreateMsgQueue(null, options);

            if (hMsgQ == IntPtr.Zero)
            {
                return(false);
            }

            hNotify = I60X0.SCA_RegisterNotification(hMsgQ);
            if (hNotify == IntPtr.Zero)
            {
                return(false);
            }

            hEvent[0] = Win32.CreateEvent(IntPtr.Zero, false, false, null);
            hEvent[1] = hMsgQ;

            scanThread = new Thread(new ThreadStart(this.ScanThreadPorc));
            scanThread.Start();

            return(true);
        }