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
+45 -2

No files matched your search

+12
View File
@@ -21,10 +21,16 @@ namespace Vocaluxe.Base
public void Close() public void Close()
{ {
if (_LogFile != null) if (_LogFile != null)
{
try
{ {
_LogFile.Flush(); _LogFile.Flush();
_LogFile.Close(); _LogFile.Close();
} }
catch (Exception)
{
}
}
} }
public void Add(string Text) public void Add(string Text)
@@ -32,9 +38,15 @@ namespace Vocaluxe.Base
if (_LogFile == null) if (_LogFile == null)
Open(); Open();
try
{
_LogFile.WriteLine(Text); _LogFile.WriteLine(Text);
_LogFile.Flush(); _LogFile.Flush();
} }
catch (Exception)
{
}
}
private void Open() private void Open()
{ {
+33 -2
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,6 +34,8 @@ namespace Vocaluxe
Application.DoEvents(); Application.DoEvents();
try
{
// Init Log // Init Log
CLog.Init(); CLog.Init();
@@ -139,14 +142,37 @@ namespace Vocaluxe
CLog.StartBenchmark(0, "Init Game"); CLog.StartBenchmark(0, "Init Game");
CGame.Init(); CGame.Init();
CLog.StopBenchmark(0, "Init Game"); 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
try
{
CSound.RecordCloseAll(); CSound.RecordCloseAll();
CSound.CloseAllStreams(); CSound.CloseAllStreams();
CVideo.VdCloseAll(); CVideo.VdCloseAll();
@@ -154,6 +180,11 @@ namespace Vocaluxe
CLog.CloseAll(); CLog.CloseAll();
CDataBase.CloseConnections(); CDataBase.CloseConnections();
} }
catch (Exception)
{
}
}
static Assembly AssemblyResolver(Object sender, ResolveEventArgs args) static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
{ {