diff --git a/CameraStream.cs b/CameraStream.cs
index b27d01e..c730e67 100644
--- a/CameraStream.cs
+++ b/CameraStream.cs
@@ -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) { }
}
diff --git a/CameraView.cs b/CameraView.cs
index 00a5d16..f4f554f 100644
--- a/CameraView.cs
+++ b/CameraView.cs
@@ -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();
diff --git a/IPCamAppBar.csproj b/IPCamAppBar.csproj
index f5568df..9e5a688 100644
--- a/IPCamAppBar.csproj
+++ b/IPCamAppBar.csproj
@@ -31,6 +31,7 @@
TRACE
prompt
4
+ false
diff --git a/MainForm.cs b/MainForm.cs
index b03ce03..ce1f956 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -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));