void DisposeInternal() { RenderingEnabled = false; Application.Idle -= new EventHandler(Application_Idle); if (!PendingTextures.Closed) { TextureThreadContextReady.Reset(); TextureThreadRunning = false; PendingTextures.Close(); TextureThreadContextReady.WaitOne(5000, false); } if (chatOverlay != null) { chatOverlay.Dispose(); chatOverlay = null; } Client.Objects.TerseObjectUpdate -= new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate); Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate); Client.Objects.AvatarUpdate -= new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate); Client.Network.UnregisterCallback(PacketType.KillObject, KillObjectHandler); Client.Network.SimChanged -= new EventHandler<SimChangedEventArgs>(Network_SimChanged); Client.Terrain.LandPatchReceived -= new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived); Client.Avatars.AvatarAnimation -= new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged); Client.Avatars.AvatarAppearance -= new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance); Client.Appearance.AppearanceSet -= new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet); if (!PendingTasks.Closed) { PendingTasks.Close(); } if (genericTaskThread != null) { genericTaskThread.Join(2000); genericTaskThread = null; } if (instance.Netcom != null) { Instance.Netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected); } lock (sculptCache) { foreach (var img in sculptCache.Values) img.Dispose(); sculptCache.Clear(); } lock (Prims) Prims.Clear(); lock (Avatars) Avatars.Clear(); TexturesPtrMap.Clear(); if (glControl != null) { glControl_UnhookEvents(); try { glControl.MakeCurrent(); } catch { } try { glControl.Dispose(); } catch { } } glControl = null; GC.Collect(); }
public SceneWindow(RadegastInstance instance) : base(instance) { InitializeComponent(); this.Instance = instance; this.Client = instance.Client; UseMultiSampling = Instance.GlobalSettings["use_multi_sampling"]; genericTaskThread = new Thread(new ThreadStart(GenericTaskRunner)); genericTaskThread.IsBackground = true; genericTaskThread.Name = "Generic task queue"; genericTaskThread.Start(); renderer = new MeshmerizerR(); renderTimer = new System.Diagnostics.Stopwatch(); renderTimer.Start(); // Camera initial setting Camera = new Camera(); InitCamera(); SetWaterPlanes(); chatOverlay = new ChatOverlay(instance, this); cbChatType.SelectedIndex = 1; DrawDistance = Instance.GlobalSettings["draw_distance"]; pnlDebug.Visible = Instance.GlobalSettings["scene_viewer_debug_panel"]; Client.Objects.TerseObjectUpdate += new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate); Client.Objects.ObjectUpdate += new EventHandler<PrimEventArgs>(Objects_ObjectUpdate); Client.Objects.AvatarUpdate += new EventHandler<AvatarUpdateEventArgs>(Objects_AvatarUpdate); Client.Network.RegisterCallback(PacketType.KillObject, KillObjectHandler); Client.Network.SimChanged += new EventHandler<SimChangedEventArgs>(Network_SimChanged); Client.Terrain.LandPatchReceived += new EventHandler<LandPatchReceivedEventArgs>(Terrain_LandPatchReceived); Client.Avatars.AvatarAnimation += new EventHandler<AvatarAnimationEventArgs>(AvatarAnimationChanged); Client.Avatars.AvatarAppearance += new EventHandler<AvatarAppearanceEventArgs>(Avatars_AvatarAppearance); Client.Appearance.AppearanceSet += new EventHandler<AppearanceSetEventArgs>(Appearance_AppearanceSet); Instance.Netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(Netcom_ClientDisconnected); Application.Idle += new EventHandler(Application_Idle); }