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()
{
if (_LogFile != null)
{
try
{
_LogFile.Flush();
_LogFile.Close();
}
catch (Exception)
{
}
}
}
public void Add(string Text)
@@ -32,9 +38,15 @@ namespace Vocaluxe.Base
if (_LogFile == null)
Open();
try
{
_LogFile.WriteLine(Text);
_LogFile.Flush();
}
catch (Exception)
{
}
}
private void Open()
{
+33 -2
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
@@ -33,6 +34,8 @@ namespace Vocaluxe
Application.DoEvents();
try
{
// Init Log
CLog.Init();
@@ -139,14 +142,37 @@ namespace Vocaluxe
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();
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
try
{
CSound.RecordCloseAll();
CSound.CloseAllStreams();
CVideo.VdCloseAll();
@@ -154,6 +180,11 @@ namespace Vocaluxe
CLog.CloseAll();
CDataBase.CloseConnections();
}
catch (Exception)
{
}
}
static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
{