예제 #1
0
        private void OnPlugInExecuteThread()
        {
            MFDevice dev = null;
            if (m_currentPlugInObject == null) return;

            try
            {
                m_deploy.OpenWithoutConnect = !m_currentPlugInObject.RequiresConnection;

                dev = ConnectToSelectedDevice();

                if (dev != null)
                {
                    if (m_currentPlugInObject.RunInSeparateThread)
                    {
                        DumpToOutput(string.Format(Properties.Resources.XCommand, m_currentPlugInObject.Name));
                    }

                    if (m_currentPlugInObject.RequiresConnection && (!dev.DbgEngine.TryToConnect(5, 100)))
                    {
                        throw new MFDeviceNoResponseException();
                    }

                    m_currentPlugInObject.OnAction(this, dev);
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception exc)
            {
                DumpToOutput(Properties.Resources.ErrorPrefix + exc.Message);
            }
            finally
            {
                DisconnectFromSelectedDevice();

                m_deploy.OpenWithoutConnect = false;

                if (m_currentPlugInObject.RunInSeparateThread)
                {
                    DumpToOutput(string.Format(Properties.Resources.StatusXComplete, m_currentPlugInObject.Name));
                }

                m_currentPlugInObject = null;
            }
        }
예제 #2
0
        // MF PlugIn Menu click
        private void OnMenuClick(object sender, EventArgs ea)
        {
            ToolStripItem tsi = sender as ToolStripItem;
            if (tsi != null)
            {
                MFPlugInMenuItem mfdp = tsi.Tag as MFPlugInMenuItem;
                if (m_pluginThread == null || !m_pluginThread.IsAlive)
                {
                    m_currentPlugInObject = mfdp;

                    // Modal dialogs need to run on the same thread
                    if (!mfdp.RunInSeparateThread)
                    {
                        OnPlugInExecuteThread();
                    }
                    else
                    {
                        m_pluginThread = new Thread(new ThreadStart(OnPlugInExecuteThread));
                        m_pluginThread.SetApartmentState(ApartmentState.STA);
                        m_pluginThread.Start();
                    }
                }
                else
                {
                    DumpToOutput(Properties.Resources.WarningPlugInPending);
                }
            }
        }