Esempio n. 1
0
        private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
        {
            int now = Environment.TickCount & Int32.MaxValue;

            m_log.ErrorFormat(
                "[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago.  {3}",
                twi.Thread.Name,
                twi.Thread.ThreadState,
                now - twi.LastTick,
                twi.AlarmMethod != null ? string.Format("Data: {0}", twi.AlarmMethod()) : "");
        }
Esempio n. 2
0
        public void AddRegion(Scene scene)
        {
            scene.RegisterModuleInterface <ITranslatorModule> (this);
            gridUserService = scene.RequestModuleInterface <IGridUserService> ();
            lock (queuelock) {
                if (service == null)
                {
                    service = new TranslatorServiceGoogle();  // TranslatorServiceMyMemory (scene);

                    // make dictionary of all language codes we accept
                    // accept both the two-letter name and the full name
                    // map both those cases to the two-letter code
                    string[] lcs = service.AllLangCodes;
                    allLangCodes    = new string[lcs.Length + 1];
                    allLangCodes[0] = NOTRANSLATE + " DISABLE";
                    Array.Copy(lcs, 0, allLangCodes, 1, lcs.Length);

                    Dictionary <string, string> lcd = new Dictionary <string, string> ();
                    foreach (string alc in allLangCodes)
                    {
                        string alclo  = alc.ToLowerInvariant();
                        int    i      = alclo.IndexOf(' ');
                        string twolet = alclo.Substring(0, i);
                        lcd.Add(twolet, twolet);
                        lcd.Add(alclo.Substring(++i), twolet);
                    }
                    langcodedict = lcd;
                }

                if (++numregions == 1)
                {
                    runthread = true;
                    Thread thread = new Thread(TranslatorThread);
                    thread.Name     = "translator";
                    thread.Priority = ThreadPriority.Normal;

                    Watchdog.ThreadWatchdogInfo info = new Watchdog.ThreadWatchdogInfo(thread, WD_TIMEOUT_MS, thread.Name);
                    Watchdog.AddThread(info, thread.Name, true);

                    thread.Start();
                }

                MainConsole.Instance.Commands.AddCommand(
                    "translator",
                    false,
                    "translator",
                    "translator [...|help|...]",
                    "run translator commands",
                    ConsoleCommand
                    );
            }
        }