public void FixtureInit()
        {
            m_app = new PcPatrBrowserApp(@"C:\carla\Dev\PcPatrBrowser\bin\Debug");
            m_sSimpleSentenceXml = Path.Combine(m_ksTestData, "SimpleSentence.xml");
            m_sComplexSentenceXml = Path.Combine(m_ksTestData, "ComplexSentence.xml");
            m_sMultiSentencesSentenceOneXml = Path.Combine(m_ksTestData, "MultiSentences1.xml");
            m_sMultiSentencesSentenceTwoXml = Path.Combine(m_ksTestData, "MultiSentences2.xml");
            m_sMultiSentencesSentenceLastXml = Path.Combine(m_ksTestData, "MultiSentencesLast.xml");

            m_sSimpleSentenceParseXml = Path.Combine(m_ksTestData, "SimpleSentenceParse.xml");
            m_sComplexSentenceParseOneXml = Path.Combine(m_ksTestData, "ComplexSentenceParse1.xml");
            m_sMultiSentencesSentenceOneParseOneXml = Path.Combine(m_ksTestData, "MultiSentences1Parse1.xml");
            m_sMultiSentencesSentenceNineParseOneXml = Path.Combine(m_ksTestData, "MultiSentences9Parse1.xml");
            m_sComplexSentenceParseTwoXml = Path.Combine(m_ksTestData, "ComplexSentenceParse2.xml");
            m_sMultiSentencesSentenceOneParseTwoXml = Path.Combine(m_ksTestData, "MultiSentences1Parse2.xml");
            m_sMultiSentencesSentenceNineParseTwoXml = Path.Combine(m_ksTestData, "MultiSentences9Parse2.xml");
        }
Beispiel #2
0
        public static int Main(string[] rgArgs)
        {
            // Create a semaphore to keep more than one instance of the application
            // from running at the same time.  If the semaphore is signalled, then
            // this instance can run.
            Win32.SecurityAttributes sa = new Win32.SecurityAttributes();
            IntPtr semaphore = Win32.CreateSemaphore(ref sa, 1, 1,
                Process.GetCurrentProcess().MainModule.ModuleName);
            switch (Win32.WaitForSingleObject(semaphore, 0))
            {
                case Win32.WAIT_OBJECT_0:
                    // Using the 'using' gizmo will call Dispose on app,
                    // which in turn will call Dispose for all FdoCache objects,
                    // which will release all of the COM objects it connects to.
                    using (PcPatrBrowserApp application = new PcPatrBrowserApp(rgArgs))
                    {
                        application.Run();
                    }
                    int previousCount;
                    Win32.ReleaseSemaphore(semaphore, 1, out previousCount);
                    break;

                case Win32.WAIT_TIMEOUT:
                    // If the semaphore wait times out then another instance is running.
                    // Try to get a handle to its window and activate it.  Then terminate
                    // this process.
                    try
                    {
                        IntPtr hWndMain = ExistingProcess.MainWindowHandle;
                        if (hWndMain != (IntPtr)0)
                            Win32.SetForegroundWindow(hWndMain);
                    }
                    catch
                    {
                        // The other instance does not have a window handle.  It is either in
                        // the process of starting up or shutting down.
                    }
                    break;
            }

            return 0;
        }