Abs
Abs

Reputation: 57916

C# Screen Capture in Parallel?

I'd like to capture a screenshot of an application's window. I can do this using the below. However, is it possible to do this in parrall or does it have to happen sequentially?

I am currently making use of this:

ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file 
Image img = sc.CaptureScreen(); // display image in a Picture control named imageDisplay 
this.imageDisplay.Image = img;  // capture this window, and save it 
sc.CaptureWindowToFile(this.Handle,"C:\\temp2.gif",ImageFormat.Gif);

Is there any way I can take screen-shots in parallel for two or more application windows?

Upvotes: 1

Views: 970

Answers (2)

Wavyx
Wavyx

Reputation: 1745

you may want to look into "threads":

Basically, you should launch concurrent threads to handle a specific work, eg giving the window handle as a parameter for the thread job.

Upvotes: 0

Scott Chamberlain
Scott Chamberlain

Reputation: 127563

I have never used that library before but from your code example it seems you are not capturing a specific window but your entire screen.

it seems you want to use the function

public void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)

and pass it the handle of the window of the application you want to capture. It seems you can use that on as many windows as you want with the library it is just a matter of getting the handle of the correct window.

Upvotes: 2

Related Questions