RequestImage() public method

Overload: Request a texture asset from the simulator using the TexturePipeline system to manage the requests and re-assemble the image from the packets received from the simulator
public RequestImage ( UUID textureID, ImageType imageType, TextureDownloadCallback callback ) : void
textureID UUID The of the texture asset to download
imageType ImageType The of the texture asset. /// Use for most textures, or for baked layer texture assets
callback TextureDownloadCallback The callback to fire when the image is retrieved. The callback /// will contain the result of the request and the texture asset data
return void
        public static void SaveAssets(AssetManager assetManager, AssetType assetType, IList<UUID> assets, string assetsPath)
        {
            int count = 0;

            List<UUID> remainingTextures = new List<UUID>(assets);
            AutoResetEvent AllPropertiesReceived = new AutoResetEvent(false);
            for (int i = 0; i < assets.Count; i++)
            {
                UUID texture = assets[i];
                if(assetType == AssetType.Texture)
                {
                    assetManager.RequestImage(texture, (state, assetTexture) =>
                    {
                        string extension = string.Empty;

                        if (assetTexture == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), assetTexture.AssetData);
                        remainingTextures.Remove(assetTexture.AssetID);
                        if (remainingTextures.Count == 0)
                            AllPropertiesReceived.Set();
                        ++count;
                    });
                }
                else
                {
                    assetManager.RequestAsset(texture, assetType, false, (transfer, asset) =>
                    {
                        string extension = string.Empty;

                        if (asset == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), asset.AssetData);
                        remainingTextures.Remove(asset.AssetID);
                        if (remainingTextures.Count == 0)
                            AllPropertiesReceived.Set();
                        ++count;
                    });
                }

                Thread.Sleep(200);
                if (i % 5 == 0)
                    Thread.Sleep(250);
            }
            AllPropertiesReceived.WaitOne(5000 + 350 * assets.Count);

            Logger.Log("Copied " + count + " textures to the asset archive folder", Helpers.LogLevel.Info);
        }