コード例 #1
0
        private void ThreadLoop(BSThreadInfo Info)
        {
            Info.Stop = false;
            long InitTime = Time;

            try
            {
            }
            catch (Exception ex)
            {
                if (ex is ThreadInterruptedException)
                {
                    return;
                }

                FrmMain.Enqueue(ex);
                File.AppendAllText(@".\Error.txt", string.Format("[{0}] {1}{2}", Now, ex, Environment.NewLine));
            }
        }
コード例 #2
0
        private void WorkLoop()
        {
            try
            {
                Time = _stopWatch.ElapsedMilliseconds;

                if (!Settings.Multithreaded)
                {
                    Settings.ThreadLimit = 1;
                }

                mThread     = new Thread[Settings.ThreadLimit];
                mThreadInfo = new BSThreadInfo[Settings.ThreadLimit];

                for (int a = 0; a < mThreadInfo.Length; a++)
                {
                    mThreadInfo[a] = new BSThreadInfo(a);
                }

                // Server System Boot
                //
                //
                StartCore();

                if (Settings.Multithreaded)
                {
                    for (int a = 0; a < mThreadInfo.Length; a++)
                    {
                        mThread[a] = new Thread(() => ThreadLoop(mThreadInfo[a]));
                        mThread[a].IsBackground = true;
                        mThread[a].Start();
                    }
                }

                // Server Network Boot
                //
                //

                try
                {
                    while (isRunning) // Core Thread Loop
                    {
                        Time = _stopWatch.ElapsedMilliseconds;
                    }
                }
                catch (Exception ex)
                {
                    FrmMain.Enqueue(ex);

                    var _st    = new StackTrace(ex, true);
                    var _frame = _st.GetFrame(0);
                    var _line  = _frame.GetFileLineNumber();

                    File.AppendAllText(@".\Error.txt", string.Format("[{0}] {1} at line {2}{3}", Now, ex, _line, Environment.NewLine));
                }

                // Server System Stop
                //
                //
            }
            catch (Exception ex)
            {
                FrmMain.Enqueue(ex);

                var _st    = new StackTrace(ex, true);
                var _frame = _st.GetFrame(0);
                var _line  = _frame.GetFileLineNumber();

                File.AppendAllText(@".\Error.txt", string.Format("[{0}] {1} at line {2}{3}", Now, ex, _line, Environment.NewLine));
            }
        }