저장 시 시간 제한 설정
Contents
[
Hide
]저장 시 시간 제한 설정
Aspose.CAD for .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(); | |
} | |
} |