예제 #1
0
        public void LoadWorker(object obj)
        {
            AyncLoader loader = obj as AyncLoader;
            int        index  = loader._minRange;

            while (index < loader._maxRange)
            {
                try
                {
                    Texture2D texture = _instance.Content.Load <Texture2D>(index.ToString());
                    _instance._textures[index] = texture;
                }
                catch (System.Exception)
                {
                }
                ++index;
                Thread.Sleep(1);
            }
        }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load <SpriteFont>("spriteFont1");

            int index     = 0;
            int increment = (int)Math.Ceiling(_numberOfTextures / (float)_numberOfWorkers);

            while (index <= _numberOfTextures)
            {
                AyncLoader worker = new AyncLoader();
                worker._minRange = index;
                worker._maxRange = Math.Min(_numberOfTextures, worker._minRange + increment);
                ParameterizedThreadStart ts = new ParameterizedThreadStart(LoadWorker);
                Thread thread = new Thread(ts);
                thread.Start(worker);
                index += increment;
            }
        }
예제 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            font = Content.Load<SpriteFont>("spriteFont1");

            int index = 0;
            int increment = (int)Math.Ceiling(_numberOfTextures / (float)_numberOfWorkers);
            while (index <= _numberOfTextures)
            {
                AyncLoader worker = new AyncLoader();
                worker._minRange = index;
                worker._maxRange = Math.Min(_numberOfTextures, worker._minRange + increment);
                ParameterizedThreadStart ts = new ParameterizedThreadStart(LoadWorker);
                Thread thread = new Thread(ts);
                thread.Start(worker);
                index += increment;
            }
        }