הגדרות זמן המתנה בעת שמירה
Contents
[
Hide
]הגדרות זמן המתנה בעת שמירה
Aspose.CAD עבור .NET API מאפשר לך להגדיר זמן המתנה בעת שמירה. זה יכול להיות מועיל במקרים שבהם תהליך השמירה לוקח הרבה זמן או צורך הרבה זיכרון. לשם כך, ה- API מספק את InterruptionTokenSource class. ה- InterruptionTokenSource class מספק טוקן המשמש להפרעת פעולות ארוכות.
דוגמת קוד
הקוד הבא מדגים את השימוש ב- InterruptionTokenSource class.
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(); | |
} | |
} |