@ -24,12 +24,27 @@ namespace MediaBrowser.ServerApplication
/// </summary>
public partial class App : Application
{
/// <summary>
/// The single instance mutex
/// </summary>
private static Mutex _singleInstanceMutex ;
/// <summary>
/// Defines the entry point of the application.
/// </summary>
[STAThread]
public static void Main ( )
{
bool createdNew ;
_singleInstanceMutex = new Mutex ( true , @"Local\" + typeof ( App ) . Assembly . GetName ( ) . Name , out createdNew ) ;
if ( ! createdNew )
{
_singleInstanceMutex = null ;
return ;
}
// Look for the existence of an update archive
var appPaths = new ServerApplicationPaths ( ) ;
var updateArchive = Path . Combine ( appPaths . TempUpdatePath , Constants . MbServerPkgName + ".zip" ) ;
@ -66,11 +81,6 @@ namespace MediaBrowser.ServerApplication
}
}
/// <summary>
/// The single instance mutex
/// </summary>
private Mutex SingleInstanceMutex ;
/// <summary>
/// Gets or sets the logger.
/// </summary>
@ -107,15 +117,6 @@ namespace MediaBrowser.ServerApplication
/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
protected override void OnStartup ( StartupEventArgs e )
{
bool createdNew ;
SingleInstanceMutex = new Mutex ( true , @"Local\" + GetType ( ) . Assembly . GetName ( ) . Name , out createdNew ) ;
if ( ! createdNew )
{
SingleInstanceMutex = null ;
Shutdown ( ) ;
return ;
}
AppDomain . CurrentDomain . UnhandledException + = CurrentDomain_UnhandledException ;
LoadKernel ( ) ;
@ -190,7 +191,10 @@ namespace MediaBrowser.ServerApplication
base . OnExit ( e ) ;
CompositionRoot . Dispose ( ) ;
if ( CompositionRoot ! = null )
{
CompositionRoot . Dispose ( ) ;
}
}
/// <summary>
@ -198,15 +202,15 @@ namespace MediaBrowser.ServerApplication
/// </summary>
private void ReleaseMutex ( )
{
if ( S ingleInstanceMutex = = null )
if ( _s ingleInstanceMutex = = null )
{
return ;
}
S ingleInstanceMutex. ReleaseMutex ( ) ;
S ingleInstanceMutex. Close ( ) ;
S ingleInstanceMutex. Dispose ( ) ;
S ingleInstanceMutex = null ;
_s ingleInstanceMutex. ReleaseMutex ( ) ;
_s ingleInstanceMutex. Close ( ) ;
_s ingleInstanceMutex. Dispose ( ) ;
_s ingleInstanceMutex = null ;
}
/// <summary>