public void LoadMap() { if (WorldMap != null) { WorldMap.Dispose(); WorldMap = null; } var worker = new BackgroundWorker(); worker.DoWork += (sender, doWorkEventArgs) => { switch (ConfigManager.Config.MapViewer.Mode) { case MapViewerMode.PreGenerated: WorldMap = Image.GetTextureFromBitmap(GraphicsDevice, @"Content\Images\highres.png"); break; case MapViewerMode.GenerateFromDAT: var mapper = new Mapper(); WorldMap = Image.GetTexture2DFromBitmap(GraphicsDevice, mapper.MapImage.Bitmap); break; } }; worker.RunWorkerAsync(); }
public async Task WorldMapDisposeTest() { var minecraftUser = new MinecraftUserMock(Guid.NewGuid()); var worldMock = new WorldMock(); var player = PlayerEntityGenerator.GeneratePlayer(minecraftUser, worldMock); var map = new WorldMap(_mapName, _serviceProvider); map.AddRegion(0, 0); map.AddPlayer(player); map.StartUpdate(); await Task.Delay(500); map.Dispose(); Assert.False(map.IsUpdating); Assert.Empty(map.Regions); Assert.Empty(map.Players); }