- Home /
How to order execution of code chunks?
I have the following code (do not pay attention that the code is repetitive). There are 3 blocks of code, each one makes a screenshot of a scene (with the same name "screen.jpg") from a different camera and adds it to a pdf file. If I do not order the code blocks execution, an exception occurs "IOException: Sharing violation on path C:\Users\E6540\AppData\LocalLow\unriale\Beds\Screenshots\screen.jpg". So, I need to make sure the first screenshot made by the first camera is added to a file, only after it's finished, the second screenshot is saved with the same name (rewritten) and added to the PDF, and finally the last one. How can I do it?
ScreenshotGenerator.TakeScreenShot();
string imagePath = Application.persistentDataPath + "/Screenshots/screen.jpg";
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imagePath);
img.Alignment = Element.ALIGN_CENTER;
img.ScaleToFit(380f, 450f);
pdfdoc.Add(img);
pdfdoc.Add(Chunk.NEWLINE);
ScreenshotGenerator.ChangeCameraTo3();
ScreenshotGenerator.TakeScreenShot();
img = iTextSharp.text.Image.GetInstance(imagePath);
img.Alignment = Element.ALIGN_CENTER;
img.ScaleToFit(380f, 450f);
pdfdoc.Add(Chunk.NEWLINE);
pdfdoc.Add(img);
ScreenshotGenerator.ChangeCameraTo4();
ScreenshotGenerator.TakeScreenShot();
img = iTextSharp.text.Image.GetInstance(imagePath);
img.Alignment = Element.ALIGN_CENTER;
img.ScaleToFit(380f, 450f);
pdfdoc.Add(Chunk.NEWLINE);
pdfdoc.Add(img);
Your answer
Follow this Question
Related Questions
Custom soundtracks? 2 Answers
iOS and Android reading/writing files 1 Answer
How to reference a file outside a project ? 1 Answer