public void mainLoop() { log("main thread running"); Thread.CurrentThread.Name = "Cache Manager mainLoop"; timer t = new timer(new TimeSpan(0, 0, 1)); while (running) { Thread.Sleep(100); if (t.elapsed) { while (watcherChangedQueue.Count > 0) processWatcherChangedQueue(); t.start(); } } log("main thread exiting"); }
public void mainLoop() { log("main thread running"); Thread.CurrentThread.Name = "Plugin Manager mainLoop"; timer t = new timer(new TimeSpan(0, 0, 1)); while (running) { Thread.Sleep(100); if (t.elapsed) { //detectPluginChanges(); t.start(); } } log("main thread exiting"); }
public void main() { try { log(Program.header); conf = new Config(); OgreWindow.Instance.textures = new Textures(ThingPath.path_cache); OgreWindow.Instance.skeletons = new Skeletons(ThingPath.path_cache); OgreWindow.Instance.meshes = new Meshes(ThingPath.path_cache); OgreWindow.Instance.materials = new Materials(); netClient = new ClientNetwork(); netClient.onLogMessage += new ClientNetwork.LogDelegate(netClient_onLogMessage); netClient.onReceiveEvent += new ClientNetwork.onReceiveEventDelegate(netClient_onReceiveEvent); netClient.onConnectCompleted += new ClientNetwork.onConnectCompletedDelegate(netClient_onConnectCompleted); netClient.onDisconnected += new ClientNetwork.onDisconnectedDelegate(netClient_onDisconnected); ClientPluginManager = new ClientPluginManager(); ClientPluginManager.onLogMessage += new LogDelegate(roomManager_onLogMessage); ClientPluginManager.onChat += new LogDelegate(ClientPluginManager_onChat); ClientPluginManager.route_toserver += new ClientPluginManager.route_toserver_delegate(clientPluginManager_route_toserver); ClientPluginManager.onListChanged += new ClientPluginManager.pluginListChangedHandler(ClientPluginManager_onListChanged); cache = new CacheManager(); cache.onLogMessage += new LogDelegate(cache_onLogMessage); cache.route_toserver += new CacheManager.route_toserverDelegate(cache_route_toserver); cache.pluginAdded += new CacheManager.pluginAddedDelegate(cache_pluginAdded); cache.pluginDeleted += new CacheManager.pluginDeletedDelegate(cache_pluginDeleted); cache.textureAdded += new CacheManager.textureAddedDelegate(cache_textureAdded); cache.textureDeleted += new CacheManager.textureDeletedDelegate(cache_textureDeleted); cache.meshAdded += new CacheManager.meshAddedDelegate(cache_meshAdded); cache.meshDeleted += new CacheManager.meshDeletedDelegate(cache_meshDeleted); cache.skeletonAdded += new CacheManager.skeletonAddedDelegate(cache_skeletonAdded); cache.skeletonDeleted += new CacheManager.skeletonDeletedDelegate(cache_skeletonDeleted); //LogManager lm = new LogManager(); OgreWindow.Instance.SceneCreating += new OgreWindow.SceneEventHandler(SceneCreating); OgreWindow.Instance.InitializeOgre(); LogManager.Singleton.DefaultLog.MessageLogged += new LogListener.MessageLoggedHandler(DefaultLog_MessageLogged); OgreWindow.Instance.mRoot.FrameStarted += new FrameListener.FrameStartedHandler(Root_FrameStarted); OgreWindow.Instance.Text = Program.header; OgreWindow.Instance.onSend += new OgreWindow.sendDelegate(Instance_onSend); OgreWindow.Instance.FormClosing += new FormClosingEventHandler(mainwindow_FormClosing); if (OgreWindow.Instance.mRoot == null) { MessageBox.Show("OgreWindow: not initialized yet"); } OgreWindow.Instance.Show(); timer t = new timer(new TimeSpan(0, 0, 2)); t.start(); try { int loops; bool b; new Thread(new ThreadStart(netConnect)).Start(); new Thread(new ThreadStart(checkPluginAddQueueLoop)).Start(); new Thread(new ThreadStart(checkNetUpdateFileQueueLoop)).Start(); new Thread(new ThreadStart(waterUpdateThread)).Start(); cache.init(); #region Primary Loop while (!OgreWindow.Instance.ShuttingDown) { if (object.Equals(null, OgreWindow.Instance.mRoot)) break; b = true; loops = 0; while (DateTime.Now.Ticks > next_game_tick && loops < MAX_FRAMESKIP) { update(); next_game_tick += SKIP_TICKS; loops++; } interpolation = (float)(DateTime.Now.Ticks + SKIP_TICKS - next_game_tick) / (float)(SKIP_TICKS); ExtraMegaBlob.References.Math.clamp_hi(1f, ref interpolation); if (!OgreWindow.Instance.pauserendering) { OgreWindow.Instance.renderingframe = true; b = OgreWindow.Instance.mRoot.RenderOneFrame(); OgreWindow.Instance.renderingframe = false; } if (!b) break; OgreWindow.Instance.doEvents(); } #endregion } catch (Exception ex) { Console.WriteLine(ex.Message); } } catch (Exception ex) { MessageBox.Show("Main: " + ex.StackTrace.ToString() + Environment.NewLine + ex.Message); if (OgreException.IsThrown) MessageBox.Show(OgreException.LastException.FullDescription, "An Ogre exception has occurred!"); } quit(); }