System.InvalidOperationException: 'Object is currently in use elsewhere.'

  • Thread starter Thread starter wqaxs36
  • Start date Start date
W

wqaxs36

Guest
This problem appear with this code

void SceneBuilder()
{
double[] VoxCube = new double[CUBE_VOLUME * BPP + OBJ_HEADER];
Bitmap Viewport = new Bitmap((int)Resolution.X, (int)Resolution.Y, (int)Resolution.X * 4, PixelFormat.Format32bppRgb, IntPtr.Zero);

VoxCube = MakeVoxCube(VoxCube);

while (true)
{
Thread.Sleep(1);

for (int Voxel = OBJ_HEADER; Voxel < (int)VoxCube[OBJ_SIZE]; Voxel++)
{
int a = ((int)VoxCube[Voxel * BPP + _x] * 500) / -(int)VoxCube[Voxel * BPP + _z];
int b = ((int)VoxCube[Voxel * BPP + _y] * 500) / -(int)VoxCube[Voxel * BPP + _z];

a = (int)Resolution.X / 2 - a;
b = (int)Resolution.Y / 2 - b;

if (a >= 0 && a < (int)Resolution.X &&
b >= 0 && b < (int)Resolution.Y)
{
Viewport.SetPixel((int)Resolution.X / 2 - (int)VoxCube[Voxel * BPP + _x], (int)Resolution.Y / 2 - (int)VoxCube[Voxel * BPP + _y], Color.FromArgb(0x0000FF00));
}
}

pictureBox1.Image = Viewport;
}
}

Continue reading...
 
Back
Top