private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc, ELogLevel.Information); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); using (CBenchmark.Time("Init Program")) { CMain.Init(); Application.DoEvents(); // Init Language using (CBenchmark.Time("Init Language")) { if (!CLanguage.Init()) { throw new CLoadingException("Language"); } } Application.DoEvents(); // load config using (CBenchmark.Time("Init Config")) { CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); } // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw using (CBenchmark.Time("Init Draw")) { if (!CDraw.Init()) { throw new CLoadingException("drawing"); } } Application.DoEvents(); // Init Playback using (CBenchmark.Time("Init Playback")) { if (!CSound.Init()) { throw new CLoadingException("playback"); } } Application.DoEvents(); // Init Record using (CBenchmark.Time("Init Record")) { if (!CRecord.Init()) { throw new CLoadingException("record"); } } Application.DoEvents(); // Init VideoDecoder using (CBenchmark.Time("Init Videodecoder")) { if (!CVideo.Init()) { throw new CLoadingException("video"); } } Application.DoEvents(); // Init Database using (CBenchmark.Time("Init Database")) { if (!CDataBase.Init()) { throw new CLoadingException("database"); } } Application.DoEvents(); //Init Webcam using (CBenchmark.Time("Init Webcam")) { if (!CWebcam.Init()) { throw new CLoadingException("webcam"); } } Application.DoEvents(); // Init Background Music using (CBenchmark.Time("Init Background Music")) { CBackgroundMusic.Init(); } Application.DoEvents(); // Init Profiles using (CBenchmark.Time("Init Profiles")) { CProfiles.Init(); } Application.DoEvents(); // Init Fonts using (CBenchmark.Time("Init Fonts")) { if (!CFonts.Init()) { throw new CLoadingException("fonts"); } } Application.DoEvents(); // Theme System using (CBenchmark.Time("Init Theme")) { if (!CThemes.Init()) { throw new CLoadingException("theme"); } } using (CBenchmark.Time("Load Theme")) { CThemes.Load(); } Application.DoEvents(); // Load Cover using (CBenchmark.Time("Init Cover")) { if (!CCover.Init()) { throw new CLoadingException("covertheme"); } } Application.DoEvents(); // Init Screens using (CBenchmark.Time("Init Screens")) { CGraphics.Init(); } Application.DoEvents(); // Init Server using (CBenchmark.Time("Init Server")) { CVocaluxeServer.Init(); } Application.DoEvents(); // Init Input using (CBenchmark.Time("Init Input")) { CController.Init(); CController.Connect(); } Application.DoEvents(); // Init Game using (CBenchmark.Time("Init Game")) { CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); } Application.DoEvents(); // Init Party Modes using (CBenchmark.Time("Init Party Modes")) { if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } } Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); } } catch (Exception e) { CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show: true); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }
private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); CLog.StartBenchmark("Init Program"); CMain.Init(); Application.DoEvents(); // Init Language CLog.StartBenchmark("Init Language"); if (!CLanguage.Init()) { throw new CLoadingException("Language"); } CLog.StopBenchmark("Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark("Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark("Init Config"); // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark("Init Draw"); if (!CDraw.Init()) { throw new CLoadingException("drawing"); } CLog.StopBenchmark("Init Draw"); Application.DoEvents(); // Init Playback CLog.StartBenchmark("Init Playback"); if (!CSound.Init()) { throw new CLoadingException("playback"); } CLog.StopBenchmark("Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark("Init Record"); if (!CRecord.Init()) { throw new CLoadingException("record"); } CLog.StopBenchmark("Init Record"); Application.DoEvents(); // Init VideoDecoder CLog.StartBenchmark("Init Videodecoder"); if (!CVideo.Init()) { throw new CLoadingException("video"); } CLog.StopBenchmark("Init Videodecoder"); Application.DoEvents(); // Init Database CLog.StartBenchmark("Init Database"); if (!CDataBase.Init()) { throw new CLoadingException("database"); } CLog.StopBenchmark("Init Database"); Application.DoEvents(); //Init Webcam CLog.StartBenchmark("Init Webcam"); if (!CWebcam.Init()) { throw new CLoadingException("webcam"); } CLog.StopBenchmark("Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark("Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark("Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark("Init Profiles"); CProfiles.Init(); CLog.StopBenchmark("Init Profiles"); Application.DoEvents(); // Init Fonts CLog.StartBenchmark("Init Fonts"); if (!CFonts.Init()) { throw new CLoadingException("fonts"); } CLog.StopBenchmark("Init Fonts"); Application.DoEvents(); // Theme System CLog.StartBenchmark("Init Theme"); if (!CThemes.Init()) { throw new CLoadingException("theme"); } CLog.StopBenchmark("Init Theme"); CLog.StartBenchmark("Load Theme"); CThemes.Load(); CLog.StopBenchmark("Load Theme"); Application.DoEvents(); // Load Cover CLog.StartBenchmark("Init Cover"); if (!CCover.Init()) { throw new CLoadingException("covertheme"); } CLog.StopBenchmark("Init Cover"); Application.DoEvents(); // Init Screens CLog.StartBenchmark("Init Screens"); CGraphics.Init(); CLog.StopBenchmark("Init Screens"); Application.DoEvents(); // Init Server CLog.StartBenchmark("Init Server"); CVocaluxeServer.Init(); CLog.StopBenchmark("Init Server"); Application.DoEvents(); // Init Input CLog.StartBenchmark("Init Input"); CController.Init(); CController.Connect(); CLog.StopBenchmark("Init Input"); Application.DoEvents(); // Init Game; CLog.StartBenchmark("Init Game"); CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); CLog.StopBenchmark("Init Game"); Application.DoEvents(); // Init Party Modes; CLog.StartBenchmark("Init Party Modes"); if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } CLog.StopBenchmark("Init Party Modes"); Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); CLog.StopBenchmark("Init Program"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message); CLog.LogError("Error on start up: " + e); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver); // Close program if there is another instance running if (!EnsureSingleInstance()) { //TODO: put it into language file MessageBox.Show("Another Instance of Vocaluxe is already runnning!"); return; } Application.DoEvents(); try { // Init Log CLog.Init(); CSettings.CreateFolders(); Application.DoEvents(); // Init Language CLog.StartBenchmark(0, "Init Language"); CLanguage.Init(); CLog.StopBenchmark(0, "Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark(0, "Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark(0, "Init Config"); Application.DoEvents(); _SplashScreen = new SplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark(0, "Init Draw"); CDraw.InitDraw(); CLog.StopBenchmark(0, "Init Draw"); Application.DoEvents(); // Init Database CLog.StartBenchmark(0, "Init Database"); CDataBase.Init(); CLog.StopBenchmark(0, "Init Database"); Application.DoEvents(); // Init Playback CLog.StartBenchmark(0, "Init Playback"); CSound.PlaybackInit(); CLog.StopBenchmark(0, "Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark(0, "Init Record"); CSound.RecordInit(); CLog.StopBenchmark(0, "Init Record"); Application.DoEvents(); //Init Webcam CLog.StartBenchmark(0, "Init Webcam"); CWebcam.Init(); CLog.StopBenchmark(0, "Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark(0, "Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark(0, "Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark(0, "Init Profiles"); CProfiles.Init(); CLog.StopBenchmark(0, "Init Profiles"); Application.DoEvents(); // Init Font CLog.StartBenchmark(0, "Init Font"); CFonts.Init(); CLog.StopBenchmark(0, "Init Font"); Application.DoEvents(); // Init VideoDecoder CLog.StartBenchmark(0, "Init Videodecoder"); CVideo.Init(); CLog.StopBenchmark(0, "Init Videodecoder"); Application.DoEvents(); // Load Cover CLog.StartBenchmark(0, "Init Cover"); CCover.Init(); CLog.StopBenchmark(0, "Init Cover"); Application.DoEvents(); // Theme System CLog.StartBenchmark(0, "Init Theme"); CTheme.InitTheme(); CLog.StopBenchmark(0, "Init Theme"); Application.DoEvents(); // Init Screens CLog.StartBenchmark(0, "Init Screens"); CGraphics.InitGraphics(); CLog.StopBenchmark(0, "Init Screens"); Application.DoEvents(); // Init Input CLog.StartBenchmark(0, "Init Input"); CInput.Init(); CLog.StopBenchmark(0, "Init Input"); // Init Game; CLog.StartBenchmark(0, "Init Game"); CGame.Init(); CLog.StopBenchmark(0, "Init Game"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message + e.StackTrace); CLog.LogError("Error on start up: " + e.Message + e.StackTrace); CloseProgram(); Environment.Exit(Environment.ExitCode); } Application.DoEvents(); // Start Main Loop _SplashScreen.Close(); try { CDraw.MainLoop(); } catch (Exception e) { MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace); CLog.LogError("Unhandled error: " + e.Message + e.StackTrace); } CloseProgram(); }