Open config file from executable directory regardless of working directory (fixes startup issue)
Fixed ExceptionEvent not invoking to main thread Bit more exception handling while shutting down
This commit is contained in:
parent
c334b7fdac
commit
5e0513fc81
@ -48,7 +48,19 @@ namespace IPCamAppBar
|
||||
public void Dispose()
|
||||
{
|
||||
cancelTaskTokenSource.Cancel();
|
||||
streamTask?.Wait();
|
||||
|
||||
try
|
||||
{
|
||||
streamTask?.Wait();
|
||||
}
|
||||
catch (AggregateException e)
|
||||
{
|
||||
if (e.InnerExceptions.Count == 1 && e.InnerExceptions[0] is TaskCanceledException)
|
||||
return;
|
||||
|
||||
throw;
|
||||
}
|
||||
catch (TaskCanceledException) { }
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace IPCamAppBar
|
||||
|
||||
Disposed += (sender, args) =>
|
||||
{
|
||||
cameraStream?.Dispose();
|
||||
cameraStream.Dispose();
|
||||
};
|
||||
}
|
||||
|
||||
@ -80,6 +80,12 @@ namespace IPCamAppBar
|
||||
|
||||
private void CameraStreamOnStreamException(object sender, StreamExceptionEventArgs args)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => { CameraStreamOnStreamException(sender, args); }));
|
||||
return;
|
||||
}
|
||||
|
||||
IssueLabel.Text = args.Exception.Message;
|
||||
IssueLabel.Visible = true;
|
||||
IssueLabel.BringToFront();
|
||||
|
@ -31,6 +31,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -16,7 +18,9 @@ namespace IPCamAppBar
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
using (var file = File.OpenText(@"config.json"))
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
using (var file = File.OpenText(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "config.json")))
|
||||
{
|
||||
var serializer = new JsonSerializer();
|
||||
config = (Config)serializer.Deserialize(file, typeof(Config));
|
||||
|
Loading…
Reference in New Issue
Block a user