public void ShowImage(Bitmap poBitmap) { // InvokeRequired compares the thread ID of the // calling thread to the thread ID of the creating thread. // If they are different, it will return true. if (picResultingBitmap.InvokeRequired) { // The calling thread is different than the UI thread // Create the delegate ShowImageCaller ldShowImage = new ShowImageCaller(ShowImage); // Invoke the delegate with an asynchronous execution // the current thread will not block until the delegate has been executed this.BeginInvoke(ldShowImage, new object[] { poBitmap }); } else { // The calling thread is the same than the UI thread // Add the string received as a parameter to the ListBox control picResultingBitmap.Image = poBitmap; } }
public void ShowImage(System.Drawing.Image paroImage) { // InvokeRequired compares the thread ID of the // calling thread to the thread ID of the creating thread. // If they are different, it will return true. if (this.InvokeRequired) { // The calling thread is different than the UI thread // Create the delegate ShowImageCaller ldAddThumbnail = new ShowImageCaller(ShowImage); // Invoke the delegate // the current thread will block until the delegate has been executed this.Invoke(ldAddThumbnail, new object[] { paroImage }); } else { // The calling thread is the same than the UI thread // Show the image in the picture box and assign its size picImage.Size = paroImage.Size; picImage.Image = paroImage; } }