/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/xmltv_parser/main.cs	2013/03/08 03:36:44	44
+++ trunk/xmltv_parser/main.cs	2013/03/08 04:01:25	46
@@ -17,6 +17,7 @@
 {
     public partial class main : Form
     {
+        bool form_closing = false;
         private IXMLTVRuntimeInstance xmltv;
         private bool IsUnix
         {
@@ -93,15 +94,22 @@
             //var program_count = p.Programs.Values.Count;
             //var program_list = p.Programs.Values.ToList().OrderBy(s => s.Start);
             ////Programs = program_list(0, program_count).ToList();
-            //Programs = new List<IXMLTVProgram>(program_list.ToArray());
-
-            xmltv = XMLTV.CreateInstance(schedule_xml);
+            //Programs = new List<IXMLTVProgram>(program_list.ToArray());            
+            xmltv = XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));
             var program_count = xmltv.Programs.Values.Count;
             var program_list = xmltv.Programs.Values.ToList().OrderBy(s => s.Start);
             //Programs = program_list(0, program_count).ToList();
             Programs = new List<IXMLTVProgram>(program_list.ToArray());
         }
 
+        void xmltv_cancelevent(object sender, CancelEventArgs e)
+        {
+            if (form_closing)
+            {
+                e.Cancel = true;
+            }
+        }
+
         void CreateControls()
         {
             foreach (var program in Programs)
@@ -168,10 +176,7 @@
 
         private void main_FormClosing(object sender, FormClosingEventArgs e)
         {
-            if (xmltv != null)
-            {
-                xmltv.Dispose();
-            }
+            form_closing = true;
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22