Release for 1.0.15 to fix mutex + black out.
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
using Microsoft.Win32;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace BodyshopPartner
|
||||
{
|
||||
@@ -15,24 +19,32 @@ namespace BodyshopPartner
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
static Mutex mutex = new Mutex(false, "ImEX Online Partner");
|
||||
|
||||
App()
|
||||
{
|
||||
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX");
|
||||
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-CA");
|
||||
|
||||
Process proc = Process.GetCurrentProcess();
|
||||
int count = Process.GetProcesses().Where(p =>
|
||||
p.ProcessName == proc.ProcessName).Count();
|
||||
|
||||
if (count > 1)
|
||||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; // Set to prevent Window black out from Material Desgin. https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/1620
|
||||
// Use a name unique to the application (eg include your company URL)
|
||||
// Wait 2 seconds if contended – in case another instance
|
||||
// of the program is in the process of shutting down.
|
||||
if (!mutex.WaitOne(TimeSpan.FromSeconds(2), false))
|
||||
{
|
||||
MessageBox.Show("ImEX Online Partner is already running.");
|
||||
App.Current.Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Application_Exit(object sender, ExitEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
mutex.ReleaseMutex();
|
||||
Utils.PowerModeEventHandler.DisposeEventHandler();
|
||||
BodyshopPartner.Properties.Settings.Default.Save();
|
||||
Utils.QuickBooksInterop.DisconnectFromQuickBooks();
|
||||
|
||||
Reference in New Issue
Block a user