Exemplo n.º 1
0
        public DriveControlServer()
        {
            InitializeComponent();

            //Is necessary for VS2005, as it checks for Thread-safty
            TextBox.CheckForIllegalCrossThreadCalls = false;

            string DataPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

            if (!DataPath.EndsWith("\\"))
            {
                DataPath += "\\";
            }

            System.IO.File.Delete(DataPath + "log.txt");
            LogFileListner = new MyTextWriterTraceListener(DataPath + "log.txt", this);
            Trace.Listeners.Add(LogFileListner);

            Trace.AutoFlush = true;
            Debug.AutoFlush = true;

            this.Show();
            Application.DoEvents();

            StartServer();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Führen Sie die Vorgänge aus, um den Dienst zu starten.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            Config = (IConfigAdapter)ObjectFactory.CreateInstance("Suchwerk.Interface.IConfigAdapter");
            string DataPath = (string)Config.Load("DataPath", "NO");

            if (System.IO.Directory.Exists(DataPath))
            {
                System.IO.File.Delete(DataPath + "log.txt");
                LogFileListner = new MyTextWriterTraceListener(DataPath + "log.txt");
                Trace.Listeners.Add(LogFileListner);
            }
            Trace.AutoFlush = true;
            Debug.AutoFlush = true;

            Thread InitThread = new Thread(new ThreadStart(StartServer));

            InitThread.Start();
        }