[longomatch] Discover file in a Task to avoid blocking the main thread
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Discover file in a Task to avoid blocking the main thread
- Date: Wed, 26 Nov 2014 15:35:17 +0000 (UTC)
commit ddf9d2fc05e81ba403df834782926e0333926413
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Nov 26 16:33:24 2014 +0100
Discover file in a Task to avoid blocking the main thread
LongoMatch.GUI.Helpers/Misc.cs | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/Misc.cs b/LongoMatch.GUI.Helpers/Misc.cs
index 970eed7..4e547ab 100644
--- a/LongoMatch.GUI.Helpers/Misc.cs
+++ b/LongoMatch.GUI.Helpers/Misc.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
using LongoMatch.Core.Store;
using LongoMatch.Core.Interfaces.GUI;
using LongoMatch.Core.Interfaces.Multimedia;
+using System.Threading.Tasks;
namespace LongoMatch.Gui.Helpers
{
@@ -299,8 +300,16 @@ namespace LongoMatch.Gui.Helpers
busy = gui.BusyDialog (Catalog.GetString("Analyzing video
file:")+"\n"+filename,
parent);
busy.Show ();
- mediaFile = multimedia.DiscoverFile (filename);
+
+ Task task = new Task ( () => {
+ mediaFile = multimedia.DiscoverFile (filename);
+ });
+ task.Start ();
+ task.Wait (6000);
busy.Destroy ();
+ if (mediaFile == null) {
+ throw new Exception(Catalog.GetString("Timeout parsing file."));
+ }
if(!mediaFile.HasVideo || mediaFile.VideoCodec == "")
throw new Exception(Catalog.GetString("This file doesn't contain a
video stream."));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]