/*! * 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(); }
/*! * 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() { SharedWorld world = SharedWorld.Get(); StopEvents = false; if (world.FileName != null) { world.LoadAsync(world.FileName, world.GetScene()); } while (!StopEvents && (SharedWorld.Get() != null)) { try { Event ev = SharedWorld.Get().NextEvent(); if (ev == null) { break; } if (ev.GetType() == typeof(TrackEvent)) { if (ev.Code != Event.TRACK) { Console.Write("ERROR: TrackEvent has bad opcode"); } } string name = ev.GetName(); EventArgs args = new VixenEventArgs(ev); object[] list = { this, args }; VixenEventHandler handler = new VixenEventHandler(PostVixenEvent); Trace("Canvas3D:Event " + name + "\n"); Invoke(handler, list); } catch (Exception ex) { LogError("exception in event loop " + ex.Message); } } if (SharedWorld.Get() != null) { SharedWorld.Get().Stop(); } }