ตั้งเวลาในขณะบันทึก
Contents
[
Hide
]ตั้งเวลาในขณะบันทึก
Aspose.CAD สำหรับ .NET API ช่วยให้คุณตั้งเวลาในขณะบันทึกได้ ซึ่งอาจมีประโยชน์ในกรณีที่กระบวนการบันทึกใช้เวลานานหรือใช้หน่วยความจำมาก สำหรับสิ่งนี้ API จะให้ InterruptionTokenSource คลาส InterruptionTokenSource จะให้โทเค็นที่ใช้ในการยุติการดำเนินการที่ยาวนาน
ตัวอย่างโค้ด
โค้ดตัวอย่างด้านล่างจะแสดงการใช้คลาส InterruptionTokenSource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
string SourceDir = RunExamples.GetDataDir_DWGDrawings(); | |
string OutputDir = RunExamples.GetDataDir_Output(); | |
using (Image cadDrawing = Image.Load(SourceDir + "Drawing11.dwg")) | |
{ | |
var rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = cadDrawing.Size.Width; | |
rasterizationOptions.PageHeight = cadDrawing.Size.Height; | |
using (var its = new InterruptionTokenSource()) | |
{ | |
PdfOptions CADf = new PdfOptions(); | |
CADf.VectorRasterizationOptions = rasterizationOptions; | |
CADf.InterruptionToken = its.Token; | |
var exportTask = Task.Factory.StartNew(() => | |
{ | |
cadDrawing.Save(OutputDir + "PutTimeoutOnSave_out.pdf", CADf); | |
}); | |
Thread.Sleep(10000); | |
its.Interrupt(); | |
exportTask.Wait(); | |
} | |
} |