added some error handling to main program

This commit is contained in:
Alexander Eckart committed 2012-04-06 16:55:48 +02:00
1 parent 1e0120faab
commit 8fd6594e19
2 files changed
+133 -90

No files matched your search

+16 -4
View File
@@ -22,8 +22,14 @@ namespace Vocaluxe.Base
{ {
if (_LogFile != null) if (_LogFile != null)
{ {
_LogFile.Flush(); try
_LogFile.Close(); {
_LogFile.Flush();
_LogFile.Close();
}
catch (Exception)
{
}
} }
} }
@@ -32,8 +38,14 @@ namespace Vocaluxe.Base
if (_LogFile == null) if (_LogFile == null)
Open(); Open();
_LogFile.WriteLine(Text); try
_LogFile.Flush(); {
_LogFile.WriteLine(Text);
_LogFile.Flush();
}
catch (Exception)
{
}
} }
private void Open() private void Open()
+117 -86
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
@@ -33,126 +34,156 @@ namespace Vocaluxe
Application.DoEvents(); Application.DoEvents();
// Init Log try
CLog.Init(); {
// Init Log
CLog.Init();
CSettings.CreateFolders(); CSettings.CreateFolders();
Application.DoEvents(); Application.DoEvents();
// Init Language // Init Language
CLog.StartBenchmark(0, "Init Language"); CLog.StartBenchmark(0, "Init Language");
CLanguage.Init(); CLanguage.Init();
CLog.StopBenchmark(0, "Init Language"); CLog.StopBenchmark(0, "Init Language");
Application.DoEvents(); Application.DoEvents();
// load config // load config
CLog.StartBenchmark(0, "Init Config"); CLog.StartBenchmark(0, "Init Config");
CConfig.LoadCommandLineParams(args); CConfig.LoadCommandLineParams(args);
CConfig.UseCommandLineParamsBefore(); CConfig.UseCommandLineParamsBefore();
CConfig.Init(); CConfig.Init();
CConfig.UseCommandLineParamsAfter(); CConfig.UseCommandLineParamsAfter();
CLog.StopBenchmark(0, "Init Config"); CLog.StopBenchmark(0, "Init Config");
Application.DoEvents(); Application.DoEvents();
_SplashScreen = new SplashScreen(); _SplashScreen = new SplashScreen();
Application.DoEvents(); Application.DoEvents();
// Init Draw // Init Draw
CLog.StartBenchmark(0, "Init Draw"); CLog.StartBenchmark(0, "Init Draw");
CDraw.InitDraw(); CDraw.InitDraw();
CLog.StopBenchmark(0, "Init Draw"); CLog.StopBenchmark(0, "Init Draw");
Application.DoEvents(); Application.DoEvents();
// Init Database // Init Database
CLog.StartBenchmark(0, "Init Database"); CLog.StartBenchmark(0, "Init Database");
CDataBase.Init(); CDataBase.Init();
CLog.StopBenchmark(0, "Init Database"); CLog.StopBenchmark(0, "Init Database");
Application.DoEvents(); Application.DoEvents();
// Init Playback // Init Playback
CLog.StartBenchmark(0, "Init Playback"); CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit(); CSound.PlaybackInit();
CLog.StopBenchmark(0, "Init Playback"); CLog.StopBenchmark(0, "Init Playback");
Application.DoEvents(); Application.DoEvents();
// Init Record // Init Record
CLog.StartBenchmark(0, "Init Record"); CLog.StartBenchmark(0, "Init Record");
CSound.RecordInit(); CSound.RecordInit();
CLog.StopBenchmark(0, "Init Record"); CLog.StopBenchmark(0, "Init Record");
Application.DoEvents(); Application.DoEvents();
// Init Background Music // Init Background Music
CLog.StartBenchmark(0, "Init Background Music"); CLog.StartBenchmark(0, "Init Background Music");
CBackgroundMusic.Init(); CBackgroundMusic.Init();
CLog.StopBenchmark(0, "Init Background Music"); CLog.StopBenchmark(0, "Init Background Music");
Application.DoEvents(); Application.DoEvents();
// Init Profiles // Init Profiles
CLog.StartBenchmark(0, "Init Profiles"); CLog.StartBenchmark(0, "Init Profiles");
CProfiles.Init(); CProfiles.Init();
CLog.StopBenchmark(0, "Init Profiles"); CLog.StopBenchmark(0, "Init Profiles");
Application.DoEvents(); Application.DoEvents();
// Init Font // Init Font
CLog.StartBenchmark(0, "Init Font"); CLog.StartBenchmark(0, "Init Font");
CFonts.Init(); CFonts.Init();
CLog.StopBenchmark(0, "Init Font"); CLog.StopBenchmark(0, "Init Font");
Application.DoEvents(); Application.DoEvents();
// Init VideoDecoder // Init VideoDecoder
CLog.StartBenchmark(0, "Init Videodecoder"); CLog.StartBenchmark(0, "Init Videodecoder");
CVideo.Init(); CVideo.Init();
CLog.StopBenchmark(0, "Init Videodecoder"); CLog.StopBenchmark(0, "Init Videodecoder");
Application.DoEvents(); Application.DoEvents();
// Load Cover // Load Cover
CLog.StartBenchmark(0, "Init Cover"); CLog.StartBenchmark(0, "Init Cover");
CCover.Init(); CCover.Init();
CLog.StopBenchmark(0, "Init Cover"); CLog.StopBenchmark(0, "Init Cover");
Application.DoEvents(); Application.DoEvents();
// Theme System // Theme System
CLog.StartBenchmark(0, "Init Theme"); CLog.StartBenchmark(0, "Init Theme");
CTheme.InitTheme(); CTheme.InitTheme();
CLog.StopBenchmark(0, "Init Theme"); CLog.StopBenchmark(0, "Init Theme");
Application.DoEvents(); Application.DoEvents();
// Init Screens // Init Screens
CLog.StartBenchmark(0, "Init Screens"); CLog.StartBenchmark(0, "Init Screens");
CGraphics.InitGraphics(); CGraphics.InitGraphics();
CLog.StopBenchmark(0, "Init Screens"); CLog.StopBenchmark(0, "Init Screens");
Application.DoEvents(); Application.DoEvents();
// Init Game;
CLog.StartBenchmark(0, "Init Game");
CGame.Init();
CLog.StopBenchmark(0, "Init Game");
// 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(); Application.DoEvents();
// Start Main Loop // Start Main Loop
_SplashScreen.Close(); _SplashScreen.Close();
CDraw.MainLoop();
try
{
CDraw.MainLoop();
}
catch (Exception e)
{
MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
}
CloseProgram();
}
static void CloseProgram()
{
// Unloading // Unloading
CSound.RecordCloseAll(); try
CSound.CloseAllStreams(); {
CVideo.VdCloseAll(); CSound.RecordCloseAll();
CDraw.Unload(); CSound.CloseAllStreams();
CLog.CloseAll(); CVideo.VdCloseAll();
CDataBase.CloseConnections(); CDraw.Unload();
CLog.CloseAll();
CDataBase.CloseConnections();
}
catch (Exception)
{
}
} }
static Assembly AssemblyResolver(Object sender, ResolveEventArgs args) static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)