Fixed "no data" message appearing immediately

Fixed TaskCanceledException handling on shutdown
This commit is contained in:
Mark van Renswoude 2019-08-23 11:18:19 +02:00
parent 346d3f5913
commit 8f61224777
3 changed files with 10 additions and 4 deletions

View File

@ -75,6 +75,9 @@ namespace IPCamAppBar
await ReadFrames(responseStream, cancellationToken);
}
}
catch (TaskCanceledException)
{
}
catch (Exception e)
{
if (cancellationToken.IsCancellationRequested)

View File

@ -9,6 +9,7 @@ namespace IPCamAppBar
public partial class CameraView : UserControl
{
private DateTime lastFrameTime;
private Timer noDataTimer;
public CameraView(string url)
@ -19,10 +20,11 @@ namespace IPCamAppBar
cameraStream.Frame += CameraStreamOnFrame;
cameraStream.Start(url);
var noDataTimer = new Timer();
noDataTimer.Interval = 1000;
noDataTimer = new Timer
{
Interval = 1000
};
noDataTimer.Tick += CheckNoData;
noDataTimer.Start();
Disposed += (sender, args) =>
{
@ -46,6 +48,7 @@ namespace IPCamAppBar
NoDataLabel.Visible = false;
lastFrameTime = DateTime.Now;
noDataTimer.Start();
var viewImage = new Bitmap(Width, Height);
using (var graphics = Graphics.FromImage(viewImage))

View File

@ -1,6 +1,6 @@
{
"AppBar": {
"Monitor": 1,
"Monitor": 0,
"Side": "Top",
"Size": 480
},