Пример #1
0
            public DocumentThreadLoader(AnimatedDocument document, Handler handler, Stream stream, Format format)
            {
                threadKilledEvent = new ManualResetEvent(false);
                quitThreadEvent   = new ManualResetEvent(false);
                this.handler      = handler;
                this.document     = document;
                this.stream       = stream;
                this.format       = format;
                loadingThread     = new Thread(Load);
                bs      = new BaudStream(stream);
                bs.Baud = document.Info.Baud;
                document.SetWaitHandler(OnWait);

                document.Info.BaudRateChanged += BaudRateChanged;
            }
Пример #2
0
 private void Load()
 {
     try
     {
         using (var context = Platform.Instance.ThreadStart())
         {
             // if switched quickly, the thread may abort here!!
             try
             {
                 running = true;
                 // only tell other threads to wait when we know we'll be getting into the 'finally' section below
                 document.LoadBase(bs, format, handler);
             }
             finally
             {
                 //running = false;
                 //Console.WriteLine("Killed!");
                 if (!aborting)
                 {
                     if (bs != null)
                     {
                         bs.Close();
                     }
                     if (stream != null)
                     {
                         stream.Close();
                     }
                     bs     = null;
                     stream = null;
                 }
             }
         }
     }
     finally
     {
         threadKilledEvent.Set();
         Debug.Print("Killed!");
     }
 }