Hi @tahir.manzoor, I have read your answers related to timeout issues. I am processing huge amount of files and I have to do Update Fields for each file. I implemented timeout using Interruption token, but since it is deprecated, can you please help me in achieving the same functionality using IPageLayoutCallback.
Code snippet I used is this one:
public Document TryToUpdateFields(Document doc, int timeout)
{
InterruptionToken token = new InterruptionToken();
bool finished = SaveWithTimeout(token,
() =>
{
token.BindToCurrentThread();
try
{
doc.UpdateFields();
}
catch (Exception ex)
{
Console.WriteLine("Interrupted");
}
}, timeout);
return doc;
}
private bool SaveWithTimeout(InterruptionToken token, ThreadStart threadStart, int timeout)
{
Thread workerThread = new Thread(threadStart);
workerThread.Start();
bool finished = workerThread.Join(timeout);
if (!finished)
{
token.Interrupt();
}
return finished;
}
Thank you,
Nimisha