Пример #1
0
 /*!
  * Events are moved from the Vixen SharedWorld to the C#
  * application through a shared event queue. Events
  * observed and handled by the Vixen SharedWorld object
  * are put into a queue. The Canvas3D class maintains a separate
  * thread which waits on this queue and converts any Vixen Events
  * it finds into C# Vixen.EventArgs and raises a .NET event
  * which can be handled in the C# application.
  */
 protected void EventLoop()
 {
     _stopevents = false;
     if ((_world == null) || (_scene == null))
     {
         return;
     }
     if ((_world.FileName != null) && SharedWorld.DoAsyncLoad)
     {
         _world.LoadAsync(_world.FileName, _scene);
     }
     while (!_stopevents)
     {
         try
         {
             Event ev = _world.NextEvent();
             if (ev == null)
             {
                 break;
             }
             string            name    = ev.GetName();
             EventArgs         args    = new VixenEventArgs(ev, RoutedVixenEvent);
             object[]          list    = { this, args };
             VixenEventHandler handler = new VixenEventHandler(PostVixenEvent);
             //SharedWorld.Trace("Canvas3D:Event " + name + "\n");
             Dispatcher.BeginInvoke(handler, list);
         }
         catch (Exception ex)
         {
             SharedWorld.LogError("exception in event loop " + ex.Message);
         }
     }
     _world.Stop();
 }