Пример #1
0
        /// <summary>
        /// ThreadMainStartup - Start RAPI connection.
        /// </summary>
        private void ThreadMainStartup()
        {
            // Allocate structure for call to CeRapiInitEx
            Rapi.RAPIINIT ri = new Rapi.RAPIINIT();
            ri.cbSize = Marshal.SizeOf(ri);

            // Call init function
            int hr = Rapi.CeRapiInitEx(ref ri);

            // Wrap event handle in corresponding .NET object
            ManualResetEvent mrev = new ManualResetEvent(false);

            mrev.Handle = ri.heRapiInit;

            // Wait five seconds, then fail.
            if (mrev.WaitOne(5000, false) && ri.hrRapiInit == Rapi.S_OK)
            {
                // Notify caller that connection established.
                itReason = INVOKE_STARTUP.STARTUP_SUCCESS;
                m_ctlInvokeTarget.Invoke(m_deleCallback);
            }
            else
            {
                // On failure, disconnect from RAPI.
                Rapi.CeRapiUninit();

                strBuffer = "Timeout - no device present.";
                itReason  = INVOKE_STARTUP.STATUS_MESSAGE;
                m_ctlInvokeTarget.Invoke(m_deleCallback);

                // Notify caller that connection failed.
                itReason = INVOKE_STARTUP.STARTUP_FAILED;
                m_ctlInvokeTarget.Invoke(m_deleCallback);
            }
        }
Пример #2
0
        StartupCallback(object sender, System.EventArgs e)
        {
            INVOKE_STARTUP it = this.m_thrdStartup.itReason;

            switch (it)
            {
            case INVOKE_STARTUP.STARTUP_SUCCESS:
                m_bRapiConnected = true;
                EnableButtons(true);
                break;

            case INVOKE_STARTUP.STARTUP_FAILED:
                EnableButtons(false);
                break;

            case INVOKE_STARTUP.STATUS_MESSAGE:
                MessageBox.Show(m_thrdStartup.strBuffer, m_strAppName);
                break;
            }
        }
Пример #3
0
        StartupCallback(object sender, System.EventArgs e)
        {
            INVOKE_STARTUP it = this.m_thrdStartup.itReason;

            switch (it)
            {
            case INVOKE_STARTUP.STARTUP_SUCCESS:
                m_bRapiConnected = true;
                EnableUI();
                break;

            case INVOKE_STARTUP.STARTUP_FAILED:
                ResetUI();
                break;

            case INVOKE_STARTUP.STATUS_MESSAGE:
                sbarMain.Text = m_thrdStartup.strBuffer;
                break;
            }
        }
Пример #4
0
        StartupCallback(object sender, System.EventArgs e)
        {
            INVOKE_STARTUP it = this.m_thrdStartup.itReason;

            switch (it)
            {
            case INVOKE_STARTUP.STARTUP_SUCCESS:
                m_bRapiConnected      = true;
                cmdInvoke.Enabled     = true;
                cmdDisconnect.Enabled = true;
                cmdConnect.Enabled    = false;
                textInput.Enabled     = true;
                break;

            case INVOKE_STARTUP.STARTUP_FAILED:
                cmdInvoke.Enabled     = false;
                cmdDisconnect.Enabled = false;
                cmdConnect.Enabled    = true;
                textInput.Enabled     = false;
                break;
            }
        } // StartupCallback
Пример #5
0
        StartupCallback(object sender, System.EventArgs e)
        {
            INVOKE_STARTUP it = this.m_thrdStartup.itReason;

            switch (it)
            {
            case INVOKE_STARTUP.STARTUP_SUCCESS:
                m_bRapiConnected      = true;
                cmdDisconnect.Enabled = true;
                cmdFetch.Enabled      = true;
                cmdConnect.Enabled    = false;
                break;

            case INVOKE_STARTUP.STARTUP_FAILED:
                MessageBox.Show("Cannot connect to device",
                                m_strAppName);
                break;

            case INVOKE_STARTUP.STATUS_MESSAGE:
                break;
            }
        } // StartupCallback