mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-19 20:03:25 +12:00
#35 [BUG] Rare ObjectDisposedException, => catch ObjectDisposedException as warning, get exceptions with full debug information, version 0.9.1.253
This commit is contained in:
parent
bb1ed20928
commit
24d88d5d87
|
@ -90,6 +90,11 @@ namespace SystemTrayMenu
|
|||
timerFadeHalf.Stop();
|
||||
timerFadeIn.Start();
|
||||
}
|
||||
else if (form.IsDisposed)
|
||||
{
|
||||
new Logger(nameof(FadeForm)).Warn(
|
||||
$"{Environment.StackTrace.ToString()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowInactiveTopmost(form);
|
||||
|
@ -161,19 +166,10 @@ namespace SystemTrayMenu
|
|||
|
||||
static void ShowInactiveTopmost(Form frm)
|
||||
{
|
||||
try
|
||||
{
|
||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||
SWP_NOACTIVATE);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger log = new Logger(nameof(FadeForm));
|
||||
log.Error($"{exception.ToString()}");
|
||||
//MessageBox.Show(exception.ToString());
|
||||
}
|
||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||
SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
}
|
31
Program.cs
31
Program.cs
|
@ -36,6 +36,9 @@ namespace SystemTrayMenu
|
|||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
Logger log = new Logger(nameof(Program));
|
||||
Logger.Start(new FileInfo(GetLogFilePath()));
|
||||
|
||||
if (IsAppAlreadyRunning("SystemTrayMenu"))
|
||||
{
|
||||
KillOtherSystemTrayMenus();
|
||||
|
@ -49,8 +52,6 @@ namespace SystemTrayMenu
|
|||
SetProcessDPIAware();
|
||||
}
|
||||
|
||||
Logger log = new Logger(nameof(Program));
|
||||
Logger.Start(new FileInfo(GetLogFilePath()));
|
||||
try
|
||||
{
|
||||
bool cancelAppRun = false;
|
||||
|
@ -78,29 +79,21 @@ namespace SystemTrayMenu
|
|||
bool killedAProcess = false;
|
||||
int ownPID = Process.GetCurrentProcess().Id;
|
||||
|
||||
foreach (Process p in Process.GetProcessesByName("SystemTrayMenu").
|
||||
Where(p => p.Id != ownPID))
|
||||
try
|
||||
{
|
||||
try
|
||||
foreach (Process p in
|
||||
Process.GetProcessesByName("SystemTrayMenu").
|
||||
Where(p => p.Id != ownPID))
|
||||
{
|
||||
p.Kill();
|
||||
p.WaitForExit();
|
||||
killedAProcess = true;
|
||||
}
|
||||
catch (Win32Exception winException)
|
||||
{
|
||||
Logger log = new Logger(nameof(Program));
|
||||
log.Error($"{winException.ToString()}");
|
||||
MessageBox.Show(winException.ToString());
|
||||
Application.Exit();
|
||||
}
|
||||
catch (InvalidOperationException invalidException)
|
||||
{
|
||||
Logger log = new Logger(nameof(Program));
|
||||
log.Error($"{invalidException.ToString()}");
|
||||
MessageBox.Show(invalidException.ToString());
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger log = new Logger(nameof(Program));
|
||||
log.Warn($"{exception.ToString()}");
|
||||
}
|
||||
|
||||
return killedAProcess;
|
||||
|
|
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.9.1.252")]
|
||||
[assembly: AssemblyFileVersion("0.9.1.252")]
|
||||
[assembly: AssemblyVersion("0.9.1.253")]
|
||||
[assembly: AssemblyFileVersion("0.9.1.253")]
|
||||
|
|
|
@ -104,6 +104,9 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<ErrorReport>none</ErrorReport>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'x64|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
|
Loading…
Reference in a new issue