views:

35

answers:

0

Hi, I i have a very simple C# Form with a thread that get's an image and saves it into a folder. In the ** line I get a Generic GDI+ Error, I believe that it's a multithreading issue.
This is the code of the thread:

    int seqId = SeqId;
    int num = 0;
    while (true)
    {
         string directoryPath = @"C:\tests\sequencias\seq-" + seqId + "\\";

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);

            }
            SRSLibraryCommon.Image img = GetImage();
            **img.InternalImage.Save(directoryPath + "img" + num + ".jpg");


            this.Invoke(new VoidDlg(delegate
            {
                this.pictureBox1.Image = (Bitmap)img.InternalImage.Clone();
            }));
            num++;
        }
    }

` Thanks. Marcos