How to interrupt or cancel process when it takes too long?
To interrupt the processing, you can use the ProgressChanged
event.
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
searchablePDFMaker.ProgressChanged += delegate(object sender, OngoingOperation operation, double progress, ref bool cancel)
{
Debug.WriteLine("Operation {0}, progress {1:F}", operation, progress);
if (stopwatch.ElapsedMilliseconds > LIMIT)
cancel = true;
}
searchablePDFMaker.MakePDFSearchable(output);