示例#1
0
        public void StartSynchronized()
        {
            Console.WriteLine("Component {0} StartSynchronized!", this);
            var ElapsedTime = Logger.Measure(() =>
            {
                ComponentThreadThread = new Thread(() =>
                {
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(GlobalConfig.ThreadCultureName);
                    try
                    {
                        Main();
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(e);
                    }
                    finally
                    {
                        Running = false;
                        RunningUpdatedEvent.Set();
                        StopCompleteEvent.Set();
                        Console.WriteLine("Component {0} Stopped!", this);
                    }
                })
                {
                    Name         = this.ThreadName,
                    IsBackground = true,
                };
                ComponentThreadThread.Start();
                ThreadTaskQueue.EnqueueAndWaitCompleted(() => { });
            });

            //Logger.Notice("Component {0} Started! StartedTime({1})", this, ElapsedTime.TotalSeconds);
            Console.WriteLine("Component {0} Started! StartedTime({1})", this, ElapsedTime.TotalSeconds);
        }
示例#2
0
        public void StartSynchronized()
        {
            Console.WriteLine("Component {0} StartSynchronized!", this);
            var StartStartTime = DateTime.Now;
            {
                ComponentThreadThread = new Thread(() =>
                {
                    ComponentThreadThread.Name          = this.ThreadName;
                    Thread.CurrentThread.CurrentCulture = new CultureInfo(PspConfig.CultureName);
                    try
                    {
                        Main();
                    }
                    finally
                    {
                        Running = false;
                        StopCompleteEvent.Set();
                        Console.WriteLine("Component {0} Stopped!", this);
                    }
                });
                ComponentThreadThread.Start();
                ThreadTaskQueue.EnqueueAndWaitCompleted(() =>
                {
                });
            }
            var StartEndTime = DateTime.Now;

            Console.WriteLine("Component {0} Started! {1}", this, StartEndTime - StartStartTime);
        }