예제 #1
0
        static void Main()
        {
            try
            {
                bool firstInstance;
                using (Mutex singleInstanceMutex = new Mutex(true, _singleInstanceGuid, out firstInstance))
                {
                    if (firstInstance)
                    {
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);

                        int port = GetFreeTcpPort(Properties.Settings.Default.EventsNetTcpPort);

                        string eventsServiceBaseUrl = String.Format(CultureInfo.InvariantCulture, "net.tcp://{0}:{1}/ArgusTV.UI.Notifier/",
                                                                    Dns.GetHostName(), port);

                        //
                        // Create the form *before* opening the host for the WCF thread synchronization context!
                        //
                        StatusForm form = new StatusForm();
                        form.EventsServiceBaseUrl = eventsServiceBaseUrl;

                        ServiceHost recordingEventsHost = EventsListenerService.CreateServiceHost(eventsServiceBaseUrl);
                        EventsListenerService.StatusForm = form;
                        recordingEventsHost.Open();

                        try
                        {
                            Application.Run(form);
                        }
                        finally
                        {
                            recordingEventsHost.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ArgusTV.UI.Notifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        static void Main()
        {
            try
            {
                bool firstInstance;
                using (Mutex singleInstanceMutex = new Mutex(true, _singleInstanceGuid, out firstInstance))
                {
                    if (firstInstance)
                    {
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);

                        int port = GetFreeTcpPort(Properties.Settings.Default.EventsNetTcpPort);

                        string eventsServiceBaseUrl = String.Format(CultureInfo.InvariantCulture, "net.tcp://{0}:{1}/ArgusTV.UI.Notifier/",
                            Dns.GetHostName(), port);

                        //
                        // Create the form *before* opening the host for the WCF thread synchronization context!
                        //
                        StatusForm form = new StatusForm();
                        form.EventsServiceBaseUrl = eventsServiceBaseUrl;

                        ServiceHost recordingEventsHost = EventsListenerService.CreateServiceHost(eventsServiceBaseUrl);
                        EventsListenerService.StatusForm = form;
                        recordingEventsHost.Open();

                        try
                        {
                            Application.Run(form);
                        }
                        finally
                        {
                            recordingEventsHost.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ArgusTV.UI.Notifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }