Ejemplo n.º 1
0
        private void ServerStartup()
        {
            setCursor(System.Windows.Forms.Cursors.WaitCursor);

            try
            {
                // Start server
                Trace.WriteLine("FMain: starting server from thread \"" +
                                System.Threading.Thread.CurrentThread.Name + "\" " +
                                " ( " + Thread.CurrentThread.ManagedThreadId.ToString() + " ) " +
                                DateTime.Now.ToLongTimeString());

                bool keepRunning = true;
                while (keepRunning)
                {
                    try
                    {
                        ServerStartupRemoting();
                        keepRunning = false;
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        ServerPort++;
                    }
                }
                ServerStartupOpenFile();
                if (myInterface.GetCompetitions().Length == 0)
                {
                    Trace.WriteLine("Not even one competition exists in newly opened file. Exiting.");

                    MessageBox.Show("I denna fil finns inte ens en enda tävling " +
                                    "definierad. Den kan därmed inte öppnas.",
                                    "Felmeddelande",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Stop);
                    Application.Exit();
                }
                ServerStartupUdpListener();
                backupWindow             = new FBackup(myInterface);
                backupWindow.EnableMain +=
                    new FBackup.EnableMainHandler(EnableMain);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Exception: " + exc.ToString());
                Trace.WriteLine("FMain: ServerStartup: Exception: " + exc.ToString());
            }
            finally
            {
                setCursor(System.Windows.Forms.Cursors.Default);

                Trace.WriteLine("FMain: ServerStartup: Done.");
            }
        }
Ejemplo n.º 2
0
		private void ServerStartup()
		{
			setCursor(System.Windows.Forms.Cursors.WaitCursor);

			try
			{
				// Start server
				Trace.WriteLine("FMain: starting server from thread \"" + 
					System.Threading.Thread.CurrentThread.Name + "\" " +
					" ( " + Thread.CurrentThread.ManagedThreadId.ToString() + " ) " +
					DateTime.Now.ToLongTimeString());

				bool keepRunning = true;
				while (keepRunning)
				{
					try
					{
						ServerStartupRemoting();
						keepRunning = false;
					}
					catch (System.Net.Sockets.SocketException)
					{
						ServerPort++;
					}
				}
				ServerStartupOpenFile();
				if (myInterface.GetCompetitions().Length == 0)
				{
					Trace.WriteLine("Not even one competition exists in newly opened file. Exiting.");

					MessageBox.Show("I denna fil finns inte ens en enda tävling " +
						"definierad. Den kan därmed inte öppnas.",
						"Felmeddelande",
						MessageBoxButtons.OK,
						MessageBoxIcon.Stop);
					Application.Exit();
				}
				ServerStartupUdpListener();
				backupWindow = new FBackup(myInterface);
				backupWindow.EnableMain += 
					new FBackup.EnableMainHandler(EnableMain);
			}
			catch (Exception exc)
			{
				MessageBox.Show("Exception: " + exc.ToString());
				Trace.WriteLine("FMain: ServerStartup: Exception: " + exc.ToString());
			}
			finally
			{
				setCursor(System.Windows.Forms.Cursors.Default);

				Trace.WriteLine("FMain: ServerStartup: Done.");
			}
		}