Çalışan Programları İzleme
** Bir çalışan programı nasıl izlenir**
Aşağıdaki örnek kod, bir çalışan programı nasıl izleyeceğinizi gösterir. Bu kod, Workbook ile ilgili kodların çalışmasını izlemek için kullanılabilir. Basitçe, bir izleme nesnesi oluşturmak için SystemTimeInterruptMonitor sınıfını kullanın, bunu LoadOptions çalışma parametrelerine eklemek için SetInterruptMonitor işlevini kullanın ve ardından StartMonitor işlevini kullanarak beklenen kesinti süresini (milisaniye cinsinden) ayarlayın. İzlenen kodun çalışma süresi beklenen süreyi aştığında, program kesilecek ve bir istisna atılacaktır.
Örnek Kod
SystemTimeInterruptMonitor monitor = new SystemTimeInterruptMonitor(false); | |
LoadOptions lopts = new LoadOptions(); | |
lopts.setInterruptMonitor(monitor); | |
monitor.startMonitor(1000); //time limit is 1 second | |
Workbook wb = new Workbook("Large.xlsx", lopts); | |
//if the time cost of loading the template file exceeds one second, interruption will be required and exception will be thrown here | |
//otherwise starts to monitor the save procedure | |
monitor.startMonitor(1500); //time limit is 1.5 seconds | |
wb.save("result.xlsx"); |